JSON errors in non-interactive auth validation#8373
Conversation
There was a problem hiding this comment.
Summary of Changes
Hello @jerop, 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 enhances the error reporting mechanism for authentication validation in non-interactive mode. It introduces the capability to output structured JSON errors for specific authentication failures, which is crucial for programmatic consumption and integration. This change ensures that applications expecting JSON output receive consistent error formats, while existing text-based error messages remain unchanged for other use cases.
Highlights
- JSON Error Output: Implemented JSON-formatted error output for non-interactive authentication validation failures, ensuring consistent machine-readable error messages when the output format is set to JSON.
- Auth Validation Scenarios: Specifically, JSON errors are now outputted when an enforced authentication type mismatches the current environment-provided auth, when no effective auth type is resolved, or when the
validateAuthMethodfunction reports an error. - Text Output Preservation: The existing text-mode error behavior is preserved for non-JSON output formats, maintaining backward compatibility for human-readable error messages.
- Comprehensive Testing: Added new unit tests for JSON auth errors in
validateNonInterActiveAuth.test.tsand an integration test case injson-output.test.tsto cover the new JSON error output scenarios.
Using Gemini Code Assist
The 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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.
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.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
7b6d2b0 to
9343e4e
Compare
There was a problem hiding this comment.
Code Review
This pull request effectively adds JSON-formatted error handling for non-interactive authentication validation, which is a great improvement for programmatic users of the CLI. The changes are well-tested with both new unit and integration tests. My main feedback is to refactor some duplicated error-handling logic in validateNonInteractiveAuth.ts to improve maintainability, for which I've provided a suggestion.
|
Size Change: +399 B (0%) Total Size: 13.2 MB ℹ️ View Unchanged
|
Code Coverage Summary
CLI Package - Full Text ReportCore Package - Full Text ReportFor detailed HTML reports, please see the 'coverage-reports-22.x-ubuntu-latest' artifact from the main CI run. |
cd72278 to
ac181bf
Compare
- Output JSON-formatted errors in non-interactive mode when: - Enforced auth type mismatches current environment-provided auth - No effective auth type is resolved - validateAuthMethod reports an error - Preserve existing text-mode behavior for non-JSON output. tests(cli): add unit tests for JSON auth errors - Add JSON-mode assertions in validateNonInterActiveAuth.test.ts - Adjust mocks to include getOutputFormat/getContentGeneratorConfig - Fix lint by using Config type instead of any test(e2e): add JSON auth error case in integration-tests - Add enforced auth mismatch test to json-output.test.ts to validate end-to-end JSON error formatting in non-interactive mode
ac181bf to
4eafef3
Compare
- Integrate PR google-gemini#8377: fix(core): stop streaming request on loop detection - Integrate PR google-gemini#8373: JSON errors in non-interactive auth validation - Update i18n tests to match new translation string format with {label} placeholders - All tests passing after merge This brings the i18n branch up to date with latest upstream changes while maintaining the complete Phase 1 internationalization implementation.
Follow up to #8119
Fixes #8022