fix: case-insensitive auth_method comparison for IDC tokens#137
Conversation
The background refresher was skipping token files with auth_method values like 'IdC' or 'IDC' because the comparison was case-sensitive and only matched lowercase 'idc'. This fix normalizes the auth_method to lowercase before comparison in: - token_repository.go: readTokenFile() when filtering tokens to refresh - background_refresh.go: refreshSingle() when selecting refresh method Fixes the issue where 'IdC' != 'idc' caused tokens to be skipped entirely.
Summary of ChangesHello @geen02, 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 where the background token refresher would incorrectly skip IDC token files due to a case-sensitive comparison of the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. 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
|
There was a problem hiding this comment.
Code Review
The pull request effectively addresses the problem of case-sensitive auth_method comparison for IDC tokens. The solution correctly normalizes the auth_method to lowercase in both token_repository.go and background_refresh.go, ensuring that all case variations are properly recognized and refreshed. The changes are well-implemented and directly resolve the identified issue, improving the robustness of the token handling logic.
Problem
The background refresher was skipping token files with
auth_methodvalues like"IdC"or"IDC"because the comparison was case-sensitive and only matched lowercase"idc".This caused the background refresher to skip your token file entirely because
"IdC" != "idc".Solution
This fix normalizes the
auth_methodto lowercase before comparison in two places:token_repository.go: InreadTokenFile()when filtering tokens to refreshbackground_refresh.go: InrefreshSingle()when selecting the appropriate refresh methodChanges
strings.ToLower()to normalizeauth_methodbefore case-sensitive comparisonsstringsimport tobackground_refresh.goTesting
The fix ensures that all case variations of IDC auth method (
"idc","IdC","IDC", etc.) are properly recognized and refreshed.