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

Bigquery: Missing Entity Type when reading dataset.access_entries #9963

Closed
tanisharai opened this issue Dec 11, 2019 · 2 comments · Fixed by #9973
Closed

Bigquery: Missing Entity Type when reading dataset.access_entries #9963

tanisharai opened this issue Dec 11, 2019 · 2 comments · Fixed by #9973
Assignees
Labels
api: bigquery Issues related to the BigQuery API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@tanisharai
Copy link

When running the following code:

from google.cloud import bigquery
gbq_client = bigquery.Client(project='project-name')
dataset_ref = gbq_client.dataset(dataset_id='dataset1', project='project-name')
dataset = gbq_client.get_dataset(dataset_ref=dataset_ref)
print(len(dataset.access_entries))

the following error will happen about 25% of the time:

Traceback (most recent call last):
  File "iam.py", line 5, in <module>
    print(len(dataset.access_entries))
  File "/usr/local/lib/python3.7/site-packages/google/cloud/bigquery/dataset.py", line 376, in access_entries
    return [AccessEntry.from_api_repr(entry) for entry in entries]
  File "/usr/local/lib/python3.7/site-packages/google/cloud/bigquery/dataset.py", line 376, in <listcomp>
    return [AccessEntry.from_api_repr(entry) for entry in entries]
  File "/usr/local/lib/python3.7/site-packages/google/cloud/bigquery/dataset.py", line 183, in from_api_repr
    return cls(role, entity_type, entity_id)
  File "/usr/local/lib/python3.7/site-packages/google/cloud/bigquery/dataset.py", line 115, in __init__
    raise ValueError(message)
ValueError: Entity type 'iamMember' not among: domain, groupByEmail, specialGroup, userByEmail, view

It seems the Google API is returning a new 'iamMember' entity type that is not in the hard coded list of allowed entity types in dataset.py

@HemangChothani HemangChothani changed the title Missing Entity Type when reading dataset.access_entries Bigquery: Missing Entity Type when reading dataset.access_entries Dec 12, 2019
@HemangChothani HemangChothani added api: bigquery Issues related to the BigQuery API. type: question Request for information or clarification. Not an issue. labels Dec 12, 2019
@HemangChothani HemangChothani self-assigned this Dec 12, 2019
@HemangChothani HemangChothani added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. and removed type: question Request for information or clarification. Not an issue. labels Dec 12, 2019
@cmc333333
Copy link

We're seeing this too, and when we do the entity_id is something like:
deleted:user:name@example.com?uid=123456789012345678901

Is there a work around?

@cmc333333
Copy link

# Nasty monkeypatch to work around
# https://github.com/googleapis/google-cloud-python/issues/9963
AccessEntry.ENTITY_TYPES = frozenset(set(AccessEntry.ENTITY_TYPES) | {"iamMember"})

seems to work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the BigQuery API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants