bigquery-emulator icon indicating copy to clipboard operation
bigquery-emulator copied to clipboard

Got an unexpected keyword argument "accessPolicyVersion"

Open pgcamus opened this issue 3 months ago • 3 comments

What happened?

Running bq mk -d {dataset} against the emulator fails with this errors:

$ bq version
This is BigQuery CLI 2.1.10
$ bq --api=http://localhost:19050/ --project_id=camus-unittest mk -d test_${RANDOM}${RANDOM}
You have encountered a bug in the BigQuery CLI. Please file a bug report in our public issue tracker:
https://issuetracker.google.com/issues/new?component=187149&template=0
Please include a brief description of the steps that led to this issue, as well as any rows that can be made public from the following information:

========================================
== Platform ==
  CPython:3.10.9:Linux-6.10.14-linuxkit-aarch64-with-glibc2.35
== bq version ==
  2.1.10
== Command line ==
  ['/usr/lib/google-cloud-sdk/platform/bq/bq.py', '--project_id=camus-infra', '--api=http://host.docker.internal:19050/', '--project_id=camus-unittest', 'mk', '-d', 'test_177583752']
== UTC timestamp ==
  2025-09-12 17:19:08
== Error trace ==
Traceback (most recent call last):
  File "/usr/lib/google-cloud-sdk/platform/bq/frontend/bigquery_command.py", line 278, in RunSafely
    return_value = self.RunWithArgs(*args, **kwds)
  File "/usr/lib/google-cloud-sdk/platform/bq/frontend/command_make.py", line 1272, in RunWithArgs
    client_dataset.CreateDataset(
  File "/usr/lib/google-cloud-sdk/platform/bq/clients/client_dataset.py", line 312, in CreateDataset
    apiclient.datasets().insert(body=body, **args).execute()
  File "/usr/lib/google-cloud-sdk/platform/bq/third_party/googleapiclient/discovery.py", line 1081, in method
    raise TypeError('Got an unexpected keyword argument "%s"' % name)
TypeError: Got an unexpected keyword argument "accessPolicyVersion"

========================================

Unexpected exception in mk operation: You have encountered a bug in the BigQuery CLI. Please file a bug report in our public issue tracker:
https://issuetracker.google.com/issues/new?component=187149&template=0
Please include a brief description of the steps that led to this issue, as well as any rows that can be made public from the following information:

What did you expect to happen?

I expected the dataset to be created.

How can we reproduce it (as minimally and precisely as possible)?

Install google-cloud-cli version 503.0.0-0 or more recent (bq version 2.1.10 or more recent) and attempt to create a dataset, e.g.

bq --api=http://localhost:19050/ --project_id=camus-unittest mk -d test_${RANDOM}${RANDOM}

Anything else we need to know?

This issue was introduced in google-cloud-cli 503.0.0-0. A workaround is to run with an older version of the package.

The root cause appears to be that GCP updated their discovery JSON document to include a new accessPolicyVersion parameter which is not present in the emulator's discovery document. The bq tool expects to be able to set this field, at which point it fails.

Updating the discovery JSON document seems like it would fix this.

pgcamus avatar Sep 12 '25 17:09 pgcamus

For posterity, I used https://gist.github.com/pgcamus/75fb1eca7b60271dd8ff524ba216e6bf to find the offending package.

pgcamus avatar Sep 12 '25 17:09 pgcamus

Bump

AntonKetska avatar Oct 06 '25 15:10 AntonKetska

Fixed by https://github.com/goccy/bigquery-emulator/pull/424

pgcamus avatar Oct 23 '25 20:10 pgcamus