fix(auth): reconcile observed OAuth scopes#660
Conversation
|
Codex review: needs changes before merge. Reviewed May 30, 2026, 2:18 PM ET / 18:18 UTC. Summary Reproducibility: yes. from source inspection. Current main does not reconcile observed refresh scopes into stored metadata, and the PR branch still has a clear split-scope service gap because Contacts requests one canonical scope at a time. Review metrics: 2 noteworthy metrics.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Copy recommended automerge instructionNext step before merge
Security Review findings
Review detailsBest possible solution: Land the reconciliation after the service-label repair checks the accumulated merged observed scope set and includes regression coverage for a split-scope service observed across multiple successful refreshes. Do we have a high-confidence way to reproduce the issue? Yes from source inspection. Current main does not reconcile observed refresh scopes into stored metadata, and the PR branch still has a clear split-scope service gap because Contacts requests one canonical scope at a time. Is this the best way to solve the issue? No, not quite. Reconciling observed scopes is the right repair direction, but the service-label check should use the accumulated merged observed scope set so split-scope services can self-heal after multiple successful calls. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model gpt-5.5, reasoning high; reviewed against 8a9a90840823. Label changesLabel changes:
Label justifications:
Evidence reviewedAcceptance criteria:
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fe3aa39ceb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
|
|
||
| if p.serviceLabel != "" { | ||
| if canonicalScopes, serviceErr := googleauth.Scopes(googleauth.Service(p.serviceLabel)); serviceErr == nil && scopesContainAll(grantedScopes, canonicalScopes) { |
There was a problem hiding this comment.
Use accumulated scopes for service repair
When a service is exercised through narrower clients, this check never backfills the service even after all of its scopes have been successfully observed. For example, the contacts clients request one scope at a time (NewPeopleContacts, NewPeopleOtherContacts, and NewPeopleDirectory in internal/googleapi/people.go:15-24), so each refresh response's grantedScopes is only a subset of the canonical contacts set; despite line 89 merging those observed scopes into updated.Scopes, this condition still tests only the current response and auth list can continue to omit contacts for a fully usable token. Consider testing the merged observed set instead of just the latest response.
Useful? React with 👍 / 👎.
Summary
Fixes #649.
Testing
go test ./internal/googleapi -run 'TestPersistingTokenSource|TestTokenSourceForAccountScopes'go test ./internal/googleapi ./internal/googleauth ./internal/cmdmake testgmail labels listreturned 16 labels; post-refreshauth listreported Gmail service and 47 scopes.