Skip to content

fix: validate universes for custom http transports - #2864

Open
daniel-sanche wants to merge 12 commits into
mainfrom
b588887517_python_track_one_google-api-python-client_02_execute-http-universe
Open

daniel-sanche wants to merge 12 commits into
mainfrom
b588887517_python_track_one_google-api-python-client_02_execute-http-universe

Conversation

@daniel-sanche

Copy link
Copy Markdown
Contributor

This library allows users to pass in custom httplib2.Http transport objects for execute() calls, which hold their own credentials. These credentials may not match the configured universe the client is talking to

This PR adds an extra validation step for these passed-in transports

@product-auto-label product-auto-label Bot added the size: l Pull request size is large. label Dec 4, 2026

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

Copy link
Copy Markdown

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 implements universe domain validation for standalone and batch HTTP requests, ensuring that credentials match the client's configured universe domain during execution, chunked uploads, and media downloads. The feedback suggests a robustness improvement in BatchHttpRequest._validate_http_credentials to filter out None transports when collecting credentials from subrequests, preventing potential errors.

Comment thread googleapiclient/http.py
Comment on lines +1365 to +1368
for transport in (http, *(self._requests[i].http for i in self._order)):
creds = _auth.get_credentials_from_http(transport)
if creds is not None:
creds_by_id[id(creds)] = creds

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Some subrequests in the batch may not have an explicit http transport configured (i.e., self._requests[i].http is None). To prevent passing None to _auth.get_credentials_from_http, filter out None transports from the iteration.

Suggested change
for transport in (http, *(self._requests[i].http for i in self._order)):
creds = _auth.get_credentials_from_http(transport)
if creds is not None:
creds_by_id[id(creds)] = creds
for transport in (http, *(self._requests[i].http for i in self._order)):
if transport is not None:
creds = _auth.get_credentials_from_http(transport)
if creds is not None:
creds_by_id[id(creds)] = creds

@daniel-sanche
daniel-sanche added this pull request to stack #2865 December 4, 2026 20:32
@daniel-sanche
daniel-sanche force-pushed the b588887517_python_track_one_google-api-python-client_02_execute-http-universe branch from b048018 to 2e0be2a Compare December 4, 2026 22:08
@daniel-sanche
daniel-sanche marked this pull request as ready for review December 4, 2026 22:08
@daniel-sanche
daniel-sanche requested a review from a team as a code owner December 4, 2026 22:08
@daniel-sanche daniel-sanche changed the title [DRAFT] fix: validate universes for custom http transports fix: validate universes for custom http transports Dec 4, 2026
Base automatically changed from b588887517_python_track_one_google-api-python-client_01_live-discovery-universe to main December 4, 2026 22:16
@daniel-sanche
daniel-sanche force-pushed the b588887517_python_track_one_google-api-python-client_02_execute-http-universe branch from 2e0be2a to 03642c3 Compare December 4, 2026 22:16

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: l Pull request size is large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant