Skip to content

fix: include amended user agent in read client#17592

Draft
tswast wants to merge 8 commits into
mainfrom
b526614511-tswast-pandas-user-agent
Draft

fix: include amended user agent in read client#17592
tswast wants to merge 8 commits into
mainfrom
b526614511-tswast-pandas-user-agent

Conversation

@tswast

@tswast tswast commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Towards internal issue b/526614511 🦕

@tswast tswast requested review from a team as code owners June 29, 2026 21:33
@tswast tswast requested review from TrevorBergeron and removed request for a team June 29, 2026 21:33

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request reorganizes imports across several files and updates the _ensure_bqstorage_client method in client.py to append pandas-gbq version information to the client_info user agent when initializing the BigQueryReadClient. It also adds comprehensive unit tests to verify this behavior under different scenarios. The review feedback suggests adding a # type: ignore[assignment] comment to the fallback assignment pandas_gbq = None to prevent potential mypy type-checking errors.

Comment thread packages/google-cloud-bigquery/google/cloud/bigquery/client.py Outdated
tswast and others added 2 commits June 29, 2026 21:36
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
gapic_version=client_info.gapic_version,
user_agent=amended_user_agent,
rest_version=client_info.rest_version,
protobuf_runtime_version=client_info.protobuf_runtime_version,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From https://github.com/googleapis/google-cloud-python/actions/runs/28405657720/job/84167435143?pr=17592,

E           AttributeError: 'ClientInfo' object has no attribute 'protobuf_runtime_version'

protobuf_runtime_version requires google-api-core 2.25 or newer: https://github.com/googleapis/python-api-core/releases/tag/v2.25.0

>>> import google.api_core.gapic_v1.client_info as client_info
>>> hasattr(client_info.ClientInfo(), 'protobuf_runtime_version')
True

See similar code in google-cloud-language:

DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
gapic_version=package_version.__version__
)
if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER
DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__

Alternatively, we could bump the minimum version of google-api-core since we currently have 2.24.2. Bumping to 2.25 seems reasonable

"google-api-core[grpc] >= 2.24.2, <3.0.0",

@parthea parthea Jun 30, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See WIP PR #17599 to bump google-api-core for generated libraries. You can also bump google-api-core in this PR for google-cloud-bigquery since it's not automatically generated .

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for investigating @parthea ! Yes, I'll bump the minimum here too.

@parthea

parthea commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Switching to draft until presubmits are green

@parthea parthea marked this pull request as draft June 30, 2026 13:32
Comment thread packages/google-cloud-bigquery/tests/unit/test_legacy_types.py Outdated
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.

2 participants