fix(auth): honor NOTION_TOKEN in auth status and doctor#62
Open
timqi wants to merge 1 commit into
Open
Conversation
auth status and auth doctor read the token directly from the config file, bypassing the NOTION_TOKEN environment variable that every other command resolves via getToken(). As a result, authenticating solely through NOTION_TOKEN made 'auth status' report '✗ Not authenticated' (and 'auth doctor' report 'no token found') even though commands like 'user me' worked fine. This regressed with the multi-profile refactor; 0.3 was unaffected. Route both commands through getToken() so env-var auth is recognized, and surface the token source (NOTION_TOKEN env vs profile).
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.
Problem
When authenticating solely via the
NOTION_TOKENenvironment variable (nonotion auth login),notion auth statusreports✗ Not authenticatedandnotion auth doctorreportsno token found, even though other commands such asnotion user mework correctly.This regressed with the multi-profile refactor —
0.3was unaffected,0.7is.Root cause
auth statusandauth doctorread the token directly from the config file (cfg.GetCurrentProfile()/cfg.Token), bypassing the sharedgetToken()helper (cmd/root.go) that every other command uses.getToken()resolves the token with env-first precedence (NOTION_TOKEN→ config profile), so env-only auth was invisible to these two commands.Fix
Route both
auth statusandauth doctorthroughgetToken(), so env-var auth is recognized consistently. Also surface the token source (NOTION_TOKEN envvs profile) in the output. Config-based profile details are only shown when a config file is actually in use.Verification
Built a fresh binary and exercised each path:
NOTION_TOKENset (valid)Source: NOTION_TOKEN envNOTION_TOKENset (invalid)token is invalid(was:Not authenticated)go build,go vet, andgo test ./cmd(18 passed) all green.🤖 Generated with Claude Code