Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix(auth): fail-fast on invalid or non-workload certificate configs in agent identity discovery#17116

Merged
chalmerlowe merged 5 commits into
googleapis:maingoogleapis/google-cloud-python:mainfrom
nbayati:fix-agent-bound-token-cert-discoverynbayati/google-cloud-python:fix-agent-bound-token-cert-discoveryCopy head branch name to clipboard
May 15, 2026
Merged

fix(auth): fail-fast on invalid or non-workload certificate configs in agent identity discovery#17116
chalmerlowe merged 5 commits into
googleapis:maingoogleapis/google-cloud-python:mainfrom
nbayati:fix-agent-bound-token-cert-discoverynbayati/google-cloud-python:fix-agent-bound-token-cert-discoveryCopy head branch name to clipboard

Conversation

@nbayati

@nbayati nbayati commented May 14, 2026

Copy link
Copy Markdown
Contributor

The GOOGLE_API_CERTIFICATE_CONFIG environment variable is shared between Managed Workload Identity (MWLID) token-binding and other flows like Enterprise Certificate Provider (ECP) configs (e.g., PKCS#11).

When this env var is set, agent identity discovery is triggered. If the config file exists but lacks the "workload" section (as with ECP configurations),we should exit early and return None to avoid delaying non-workload flows.

In addition, if the config file on disk had syntax errors or invalid JSON, the previous logic entered a 30-second blocking retry loop before failing with RefreshError. To resolve this, the lookup logic now assumes that if the config file exists on disk, it is in its final format. If the file exists but lacks a "workload" section, has syntax errors, or is unreadable, we return None immediately to fail-fast and avoid startup delays.

b/512912028
fixes #17145

…n agent identity discovery

The `GOOGLE_API_CERTIFICATE_CONFIG` environment variable is shared between Managed Workload Identity (MWLID) token-binding and other flows like Enterprise Certificate Provider (ECP) configs (e.g., PKCS#11).

When this env var is set, agent identity discovery is triggered. If the config file exists but lacks the `"workload"` section (as with ECP configurations),we should exit early and return `None` to avoid delaying non-workload flows.

In addition, if the config file on disk had syntax errors or invalid JSON, the previous logic entered a 30-second blocking retry loop before failing with `RefreshError`.
To resolve this, the lookup logic now assumes that if the config file exists on disk, it is in its final format. If the file exists but lacks a `"workload"` section, has syntax errors, or is unreadable, we return `None` immediately to fail-fast and avoid startup delays.
@nbayati nbayati requested review from a team as code owners May 14, 2026 00:26

@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 refactors the get_agent_identity_certificate_path function to support a well-known workload directory fallback and improves the robustness of configuration parsing with better type checking and fail-fast logic. New test cases were added to cover various invalid configuration scenarios. Feedback was provided to add an explicit type check for the cert_configs dictionary to prevent a potential AttributeError and to raise an error instead of returning None for malformed configurations.

Comment thread packages/google-auth/google/auth/_agent_identity_utils.py Outdated
Comment thread packages/google-auth/google/auth/_agent_identity_utils.py
Comment thread packages/google-auth/google/auth/_agent_identity_utils.py Outdated

@agrawalradhika-cell agrawalradhika-cell 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.

Provided some minor comments, rest looks good!

@chalmerlowe chalmerlowe merged commit f27a546 into googleapis:main May 15, 2026
31 checks passed
suztomo added a commit that referenced this pull request May 15, 2026
PR created by the Librarian CLI to initialize a release. Merging this PR
will auto trigger a release.

Librarian Version: v0.13.0
Language Image:
us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/python-librarian-generator@sha256:234b9d1f2ddb057ed7ac6a38db0bf8163d839c65c6cf88ade52530cddebce59e
<details><summary>google-auth: v2.53.0</summary>

##
[v2.53.0](suztomo/google-cloud-python@google-auth-v2.52.0...google-auth-v2.53.0)
(2026-05-15)

### Bug Fixes

* allowlist agents-nonprod trust domains for agent identity (#17155)
([44c93d2](suztomo@44c93d2e))

* fail-fast on invalid or non-workload certificate configs in agent
identity discovery (#17116)
([f27a546](suztomo@f27a5461))

</details>

b/513591686
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.

Auth: docs CI check fails due to upstream requests 2.34.x docstring formatting regression

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.