fix: enhance account resolution and export command handling#141
fix: enhance account resolution and export command handling#141iamrajiv wants to merge 3 commits intogoogleworkspace:mainfrom
Conversation
🦋 Changeset detectedLatest commit: e7244d4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 authentication system by fixing two long-standing bugs. It ensures that users with older credential formats can authenticate correctly without encountering 401 errors and provides more robust and user-friendly control over credential exports, particularly for multi-account setups. The changes also improve diagnostic capabilities by making authentication failures visible to the user. 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
|
|
can you rebase? |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #141 +/- ##
==========================================
+ Coverage 54.88% 55.43% +0.54%
==========================================
Files 38 38
Lines 13085 13163 +78
==========================================
+ Hits 7182 7297 +115
+ Misses 5903 5866 -37 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Code Review
This pull request effectively addresses the reported issues regarding legacy credential handling and enhances the auth export command. The changes in src/auth.rs correctly modify resolve_account to return Ok(None) for legacy credentials without a registry, allowing for proper fallback. The src/main.rs update to log credential loading errors to stderr significantly improves user diagnosability, preventing silent 401 errors. Furthermore, the src/auth_commands.rs modifications introduce --account support and --unmasked documentation for the export command, along with appropriate argument parsing and credential loading logic. The added test cases provide good coverage for the new and modified functionalities.
|
@gmail personal account since 2004 so i guess i will wait for this fix to enter stable release 😃 |
Description
Fixes #137
Two bugs caused auth to be broken for users with legacy (pre-multi-account) credentials.
Bug 1: 401 on all commands despite successful auth
resolve_account()inauth.rswouldbail!when it found legacycredentials.encwithout an account registry (accounts.json), demanding users re-login. Butget_token()already handlesOk(None)by falling back to the legacy credential path — the bail was actively preventing valid credentials from being used.The error was then silently swallowed in
main.rs:This resulted in unauthenticated requests and 401 responses.
Fix:
resolve_account()now returnsOk(None)for the legacy case, allowingget_token()to use the legacy path naturally. Additionallymain.rsnow logs credential errors to stderr instead of silently discarding them.Bug 2:
auth exportoutputs masked/truncated credentialsThe masking is intentional as a security default, but the
--unmaskedflag was undocumented and the command lacked--accountsupport. It always read from the legacycredentials.encpath, failing for multi-account users.Fix:
handle_exportnow resolves accounts the same wayget_tokendoes, supports--account EMAIL, and the help text documents both--unmaskedand--account.Changes
src/auth.rs—resolve_account()returnsOk(None)instead of bailing on legacy credentials; madepubfor reusesrc/auth_commands.rs—handle_exportgains--accountsupport, usesload_encrypted_from_pathwith resolved path, help text updatedsrc/main.rs— credential loading errors logged to stderr instead of silently discardedChecklist
AGENTS.mdguidelines (no generatedgoogle-*crates).cargo fmt --allto format the code perfectly.cargo clippy -- -D warningsand resolved all warnings.pnpx changeset) to document my changes.