fix(a2a-server): prioritize ADC before evaluating headless constraints for auth initialization#23614
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical bug that prevented headless authentication in certain scenarios by incorrectly evaluating interactive mode constraints too early. The authentication flow has been refactored to first attempt authentication via Application Default Credentials (ADC). This ensures that background agents and other headless processes can successfully authenticate using explicitly provided ADC paths, improving reliability and user experience for non-interactive environments. The changes also provide more informative error messages when authentication attempts fail. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
The pull request refactors the authentication flow to prioritize COMPUTE_ADC over LOGIN_WITH_GOOGLE. The system now attempts COMPUTE_ADC first, and only falls back to LOGIN_WITH_GOOGLE if COMPUTE_ADC fails and an interactive session is available. If both authentication methods fail, the error message now includes details from both attempts. The reviewer suggests improving the clarity of an error message to accurately reflect that COMPUTE_ADC is the initial attempt, not a fallback, when both methods fail.
|
Size Change: +56 B (0%) Total Size: 26.4 MB
ℹ️ View Unchanged
|
0aa4df9 to
fe4ddd1
Compare
3a363f6 to
49743f3
Compare
…s for auth initialization
49743f3 to
0a1cedb
Compare
…s for auth initialization (#23614)
…s for auth initialization (google-gemini#23614)
…s for auth initialization (google-gemini#23614)
Summary
This PR fixes a bug introduced in #21045 that inadvertently prevented headless authentication using
GOOGLE_APPLICATION_CREDENTIALS(orGEMINI_CLI_USE_COMPUTE_ADC).Previously, the logic immediately evaluated
isHeadlessMode()and threw aFatalAuthenticationErrorif headless, completely blocking processes like IDE background agents from authenticating via explicitly provided ADC paths.Details
This update refactors the authentication flow in
packages/a2a-server/src/config/config.tsto prioritizeCOMPUTE_ADC. It now attempts to load and validate credentials viaCOMPUTE_ADCbefore evaluating any interactive/headless constraints. If the credentials are valid, the interactive flow and headless checks are bypassed. If ADC fails, it will properly throw aFatalAuthenticationErrorin headless environments (or fall back toLOGIN_WITH_GOOGLEin interactive ones), appending the reason for the ADC failure.I also updated
packages/a2a-server/src/config/config.test.tsto ensure these behaviors are fully covered.Related Issues
Fixes #1598
How to Validate
Run tests inside
packages/a2a-server:npm test -w @google/gemini-cli-a2a-serverPre-Merge Checklist