Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: init_es.py script not completing due to AttributeError #1309

Merged
merged 1 commit into from
Aug 23, 2023

Conversation

vinmh
Copy link
Contributor

@vinmh vinmh commented Aug 8, 2023

This PR fixes a small bug in the querybook.server.logic.elasticsearch._bulk_insert_users() function. The get_users_iter function used to return a dict object representation of the users in the database, but the _bulk_insert_users function tries to access the is_group attribute found in the User SQLAlchemy model.

Running this function with users already present in the database (usually through the init_es.py script invoked by --initdb) results in the following error:

Traceback (most recent call last):
  File “<stdin>“, line 1, in <module>
  File “/opt/querybook/querybook/server/logic/elasticsearch.py”, line 725, in _bulk_insert_users
    if not user.is_group:
AttributeError: ‘dict’ object has no attribute ‘is_group’

The proposed fix is to return User instances from the get_users_iter function and then convert them to ElasticSearch compatible dict objects in the functions that need it (_bulk_insert_users() and _bulk_update_users(fields: Set[str] = None)).

@vinmh vinmh changed the title fix: init_es.py script not completing due to TypeError fix: init_es.py script not completing due to AttributeError Aug 8, 2023
@czgu czgu merged commit 2625209 into pinterest:master Aug 23, 2023
4 checks passed
aidenprice pushed a commit to arrowtail-precision/querybook that referenced this pull request Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants