fix(auth): update config file when switching default grant#14
Merged
qasim-nylas merged 1 commit intonylas:mainfrom Feb 3, 2026
Merged
Conversation
Previously, `nylas auth switch` only updated the default grant in the keyring but not in the config file (~/.config/nylas/config.yaml). This caused the config file to show stale default_grant values. Now both SwitchGrant and SwitchGrantByEmail update the keyring (authoritative) and the config file. Config save errors are non-fatal since the keyring is the source of truth. Added unit tests for GrantService switch operations.
qasim-nylas
approved these changes
Feb 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
nylas auth switchonly updated the default grant in the keyring but not in the config file (~/.config/nylas/config.yaml)default_grantfield remained stale after switching accountsSwitchGrantandSwitchGrantByEmailupdate the keyring (authoritative source) and the config fileProblem
When running
nylas auth switch <email>:nylas auth listshowed the correct default (reads from keyring) ✓~/.config/nylas/config.yamlstill showed the olddefault_grantvalue ✗This inconsistency caused confusion when inspecting the config file directly.
Solution
Added a
setDefaultGrant()helper method inGrantServicethat updates both:grantStore.SetDefaultGrant()- authoritative sourceconfig.Load()→ setDefaultGrant→config.Save()Config save errors are non-fatal since the keyring is the source of truth.
Changes
internal/app/auth/grants.go: AddedsetDefaultGrant()helper, updatedSwitchGrant()andSwitchGrantByEmail()to use itinternal/app/auth/grants_test.go: Added comprehensive unit tests forGrantServiceswitch operationsTest plan
go test ./internal/app/auth/...)make cipasses (fmt, vet, lint, tests, security, vuln)nylas auth switch <email>updates both keyring and config file