Skip to content

fix(aith): exit early when agent cert config is outside well-known directory#17762

Open
nbayati wants to merge 2 commits into
googleapis:mainfrom
nbayati:skip-polling-if-not-explicitly-set
Open

fix(aith): exit early when agent cert config is outside well-known directory#17762
nbayati wants to merge 2 commits into
googleapis:mainfrom
nbayati:skip-polling-if-not-explicitly-set

Conversation

@nbayati

@nbayati nbayati commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

To prevent unnecessary startup latency, this updates the agent certificate retrieval to only poll when the config points to the well-known workload directory (where Cloud Run dynamically mounts files). For all other paths, it exits early.

  • Extracts config parsing into a dedicated helper function
  • Removes the hardcoded fallback to the well-known path when no config is provided
  • Adds test coverage for new logic

fixes b/522957573

…ectory

To prevent unnecessary startup latency, this updates the agent certificate retrieval to only poll when the config points to the well-known workload directory (where Cloud Run dynamically mounts files). For all other paths, it exits early.

- Extracts config parsing into a dedicated helper function
- Removes the hardcoded fallback to the well-known path when no config is provided
- Adds test coverage for new logic
@nbayati
nbayati requested review from a team as code owners July 17, 2026 06:42

@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 agent identity certificate path retrieval logic in _agent_identity_utils.py by extracting configuration parsing and polling into dedicated helper functions, and conditionally disabling polling for paths outside the well-known directory to avoid startup delays. The review feedback recommends specifying encoding="utf-8" when opening the configuration file to ensure consistent cross-platform behavior.

"""
import json

with open(cert_config_path, "r") as f:

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.

medium

Specify encoding="utf-8" when opening the configuration file to ensure consistent behavior across different platforms (such as Windows) where the default system encoding might not be UTF-8.

Suggested change
with open(cert_config_path, "r") as f:
with open(cert_config_path, "r", encoding="utf-8") as f:

@nbayati nbayati changed the title refactor: exit early when agent cert config is outside well-known directory fix(aith): exit early when agent cert config is outside well-known directory Jul 17, 2026
@parthea parthea added kokoro:force-run Add this label to force Kokoro to re-run the tests. kokoro:run Add this label to force Kokoro to re-run the tests. labels Jul 17, 2026
@yoshi-kokoro yoshi-kokoro removed kokoro:run Add this label to force Kokoro to re-run the tests. kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Jul 17, 2026
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.

3 participants