fix: log auth errors to stderr instead of silently discarding#190
fix: log auth errors to stderr instead of silently discarding#190Bortlesboat wants to merge 1 commit intogoogleworkspace:mainfrom
Conversation
🦋 Changeset detectedLatest commit: 8408910 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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 significantly enhances the user experience of the CLI by addressing a critical issue where OAuth authentication failures were previously suppressed. By explicitly logging these errors to stderr and providing actionable advice, users will now immediately understand why their commands are failing, thereby reducing frustration and debugging time. Highlights
Changelog
Activity
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. 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
|
When OAuth authentication fails in the main CLI flow, the error was silently discarded (`Err(_) => (None, AuthMethod::None)`) and the request proceeded unauthenticated. Users then received confusing 401/403 API errors with no indication of the actual root cause. Now prints the original error message and a hint to run `gws auth login` to stderr, so users immediately understand why their request failed.
e9c0694 to
8408910
Compare
There was a problem hiding this comment.
Code Review
This pull request modifies the main CLI flow to log authentication failures to stderr instead of silently discarding them. The change includes printing the error and a hint for the user. My feedback includes a suggestion to make the hint more comprehensive.
| Err(_) => (None, executor::AuthMethod::None), | ||
| Err(e) => { | ||
| eprintln!("warning: authentication failed: {e:#}"); | ||
| eprintln!("hint: run `gws auth login` to authenticate, or set GOOGLE_WORKSPACE_CLI_TOKEN"); |
There was a problem hiding this comment.
The hint about authentication methods is helpful, but it's incomplete. It omits the GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE environment variable, which is another primary way to provide credentials. To provide a more comprehensive hint to the user, it would be better to include it.
| eprintln!("hint: run `gws auth login` to authenticate, or set GOOGLE_WORKSPACE_CLI_TOKEN"); | |
| eprintln!("hint: run `gws auth login` to authenticate, or set GOOGLE_WORKSPACE_CLI_TOKEN or GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE"); |
Summary
When OAuth authentication fails in the main CLI flow, the error was silently discarded and the request proceeded unauthenticated. Users then received confusing 401/403 API errors with no indication of the root cause (expired token, missing credentials, wrong account, etc.).
Now prints the original error message and a hint to stderr.
Changes
src/main.rs: ReplaceErr(_) => (None, AuthMethod::None)with logging the error and a hint to rungws auth loginNote: The MCP server (
mcp_server.rs:430-435) already logs auth failures correctly — this brings the main CLI in line with that pattern.Test plan
cargo test,cargo clippy,cargo fmt