Skip to content

feat: add SetShouldRefreshGate to gate OAuth token sweep ticks - #5812

Merged
Pratham-Mishra04 merged 1 commit into
devfrom
08-03-feat_allow_gating_oauthtokenrefreshworker_sweeps
Aug 8, 2026
Merged

Pratham-Mishra04 merged 1 commit into
devfrom
08-03-feat_allow_gating_oauthtokenrefreshworker_sweeps

Conversation

@Pratham-Mishra04

Copy link
Copy Markdown
Collaborator

Summary

Adds a configurable gate to OAuthTokenRefreshWorker that controls whether a sweep tick proceeds. This allows deployments running multiple workers against a shared token store to prevent concurrent token refreshes of the same token.

Changes

  • Added a shouldRefresh atomic pointer field to OAuthTokenRefreshWorker that holds an optional predicate function
  • Added SetShouldRefreshGate method to install or clear the gate at any time, including while the worker is running
  • At the start of each refreshExpiredTokens call, the gate (if set) is evaluated and the sweep is skipped if it returns false
  • When no gate is set, behavior is unchanged (sweeps always run)

Type of change

  • Bug fix
  • Feature
  • Refactor
  • Documentation
  • Chore/CI

Affected areas

  • Core (Go)
  • Transports (HTTP)
  • Providers/Integrations
  • Plugins
  • UI (React)
  • Docs

How to test

go test ./framework/oauth2/...

Verify that:

  • When no gate is set, token refresh sweeps proceed as normal
  • When a gate returning false is installed, refreshExpiredTokens returns early without querying or refreshing tokens
  • When a gate returning true is installed, sweeps proceed normally
  • Calling SetShouldRefreshGate(nil) restores default behavior

Screenshots/Recordings

N/A

Breaking changes

  • Yes
  • No

Related issues

Security considerations

The gate function receives a context.Context, which may carry request-scoped values. Care should be taken that any gate implementation does not inadvertently expose or leak sensitive context values.

Checklist

  • I read docs/contributing/README.md and followed the guidelines
  • I added/updated tests where appropriate
  • I updated documentation where needed
  • I verified builds succeed (Go and UI)
  • I verified the CI pipeline passes locally if applicable

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

This was referenced Aug 3, 2026
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@Pratham-Mishra04
Pratham-Mishra04 force-pushed the 08-03-chore_add_resolve-pr-comments-stack_skill branch from 35682af to c9302d4 Compare August 8, 2026 08:43
@Pratham-Mishra04
Pratham-Mishra04 force-pushed the 08-03-feat_allow_gating_oauthtokenrefreshworker_sweeps branch from 02b9c4e to a824e01 Compare August 8, 2026 08:43
@Pratham-Mishra04
Pratham-Mishra04 force-pushed the 08-03-chore_add_resolve-pr-comments-stack_skill branch from c9302d4 to 4a3b2af Compare August 8, 2026 10:15
@Pratham-Mishra04
Pratham-Mishra04 requested a review from a team as a code owner August 8, 2026 10:15
@Pratham-Mishra04
Pratham-Mishra04 force-pushed the 08-03-feat_allow_gating_oauthtokenrefreshworker_sweeps branch from a824e01 to 9006c78 Compare August 8, 2026 10:16
@Pratham-Mishra04
Pratham-Mishra04 changed the base branch from 08-03-chore_add_resolve-pr-comments-stack_skill to graphite-base/5812 August 8, 2026 10:29
@Pratham-Mishra04
Pratham-Mishra04 force-pushed the 08-03-feat_allow_gating_oauthtokenrefreshworker_sweeps branch from 9006c78 to fe06822 Compare August 8, 2026 10:29

Pratham-Mishra04 commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator Author

Merge activity

  • Aug 8, 10:33 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Aug 8, 10:47 AM UTC: Graphite rebased this pull request as part of a merge.
  • Aug 8, 10:48 AM UTC: @Pratham-Mishra04 merged this pull request with Graphite.

@Pratham-Mishra04
Pratham-Mishra04 changed the base branch from graphite-base/5812 to dev August 8, 2026 10:45
@Pratham-Mishra04
Pratham-Mishra04 dismissed coderabbitai[bot]’s stale review August 8, 2026 10:45

The base branch was changed.

@Pratham-Mishra04
Pratham-Mishra04 force-pushed the 08-03-feat_allow_gating_oauthtokenrefreshworker_sweeps branch from fe06822 to c50bea4 Compare August 8, 2026 10:47
@Pratham-Mishra04
Pratham-Mishra04 merged commit e08d12c into dev Aug 8, 2026
14 of 15 checks passed
@Pratham-Mishra04
Pratham-Mishra04 deleted the 08-03-feat_allow_gating_oauthtokenrefreshworker_sweeps branch August 8, 2026 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants