fix: exclude terminal-status oauth configs from expiring token refresh query - #4754
Conversation
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 9 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthrough
ChangesTerminal OAuth config exclusion
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
|
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (7): Last reviewed commit: "fix: stop token refresh worker from retr..." | Re-trigger Greptile |
92bc69c to
e1cdee5
Compare
6f31c89 to
e424bd0
Compare
e1cdee5 to
ad3df93
Compare
e424bd0 to
5888e03
Compare
ad3df93 to
a9fef25
Compare
5888e03 to
9b9c2d9
Compare
a9fef25 to
6686182
Compare
9b9c2d9 to
500e369
Compare
6686182 to
6673c1a
Compare
500e369 to
36bd514
Compare
Merge activity
|
The base branch was changed.
36bd514 to
aa1ca02
Compare
…h query (#4754) ## Summary The OAuth token refresh worker was repeatedly selecting permanently-dead tokens on every tick because their `expires_at` timestamp remains in the past after a terminal failure (e.g., `invalid_grant` / "Grant not found"). This caused the same error to be logged indefinitely. Tokens whose owning `oauth_config` has reached a terminal state (`expired` or `revoked`) no longer need to be refreshed — they require re-authorization instead. ## Changes - `GetExpiringOauthTokens` now excludes tokens whose associated `oauth_config` has a status of `expired` or `revoked`, using a `NOT EXISTS` subquery. This prevents the refresh worker from endlessly retrying permanently-dead grants. - A new test, `TestGetExpiringOauthTokens_ExcludesTerminalConfigs`, validates that tokens linked to terminal configs are excluded from the result, while tokens with an active (`authorized`) config or no config at all are still returned. ## Type of change - [x] Bug fix - [ ] Feature - [ ] Refactor - [ ] Documentation - [ ] Chore/CI ## Affected areas - [x] Core (Go) - [ ] Transports (HTTP) - [ ] Providers/Integrations - [ ] Plugins - [ ] UI (React) - [ ] Docs ## How to test ```sh go test ./framework/configstore/... -run TestGetExpiringOauthTokens_ExcludesTerminalConfigs -v ``` Expected: the test passes, confirming that tokens with `expired` or `revoked` configs are excluded, while tokens with `authorized` configs or no config are included. ## Breaking changes - [ ] Yes - [x] No ## Related issues ## Security considerations This change reduces unnecessary outbound refresh requests for revoked or expired OAuth grants, which could otherwise leak information about token state to external authorization servers on every refresh tick. ## Checklist - [ ] I read `docs/contributing/README.md` and followed the guidelines - [x] I added/updated tests where appropriate - [ ] I updated documentation where needed - [x] I verified builds succeed (Go and UI) - [ ] I verified the CI pipeline passes locally if applicable

Summary
The OAuth token refresh worker was repeatedly selecting permanently-dead tokens on every tick because their
expires_attimestamp remains in the past after a terminal failure (e.g.,invalid_grant/ "Grant not found"). This caused the same error to be logged indefinitely. Tokens whose owningoauth_confighas reached a terminal state (expiredorrevoked) no longer need to be refreshed — they require re-authorization instead.Changes
GetExpiringOauthTokensnow excludes tokens whose associatedoauth_confighas a status ofexpiredorrevoked, using aNOT EXISTSsubquery. This prevents the refresh worker from endlessly retrying permanently-dead grants.TestGetExpiringOauthTokens_ExcludesTerminalConfigs, validates that tokens linked to terminal configs are excluded from the result, while tokens with an active (authorized) config or no config at all are still returned.Type of change
Affected areas
How to test
go test ./framework/configstore/... -run TestGetExpiringOauthTokens_ExcludesTerminalConfigs -vExpected: the test passes, confirming that tokens with
expiredorrevokedconfigs are excluded, while tokens withauthorizedconfigs or no config are included.Breaking changes
Related issues
Security considerations
This change reduces unnecessary outbound refresh requests for revoked or expired OAuth grants, which could otherwise leak information about token state to external authorization servers on every refresh tick.
Checklist
docs/contributing/README.mdand followed the guidelines