Repository navigation
fix(auth): clear request state outside jersey - #36173
Conversation
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
Code Review ✅ Approved🔴 High risk · Request-wide context cleanup and fresh token-user reads change authentication decisions; incorrect scoping could reuse stale credentials or reject valid tokens. Adds VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
|
✅ SSO Login Nightly — PASSED View workflow run · Commit
Totals: 94 passed · 0 failed · 0 flaky · 0 skipped · duration 17m 15s |
Describe your changes:
Part of a larger set of MCP and auth fixes.
PerRequestContextCleanupFilteron/*clears that state before and after every request on the application context. The bot and personal access token loaders also read the user insideFreshReadScope, which covers threads the filter does not wrap.ADR:2026-10-23-every-jetty-request-clears-per-request-thread-state.Type of change:
Tests:
Unit tests
PerRequestContextCleanupFilterTest(3),BotTokenCacheTest(1) andUserTokenCacheTest(1); each fails with its change reverted.PerRequestContextCleanerTest,RequestEntityCacheTest,CredentialTokenStateTest,SocketAddressFilterTestalso pass.Backend integration tests
Not run locally (touching
OpenMetadataApplicationselects the full suite); the merge queue runs them.Checklist:
REVIEW.md(thepr-checklistskill runs it) and fixed every 🔴 finding, or answered it on the line below.Reviewed
378322e. No 🔴. 🟡UserTokenCachehad no test: addedUserTokenCacheTestin9600884. 🟡 nothing tests the filter's registration order: the decision record names the reviewer as its guard; an IT needs a new accessor on the test bootstrap, left for a follow-up.ADR:2026-10-23-every-jetty-request-clears-per-request-thread-state.

Confidence Score: 5/5
The PR appears safe to merge; no actionable defects were found.Summary
Adds cleanup before and after application requests, including handlers outside Jersey.
No actionable issues were found. Tests were inspected, not run.
Vishnuujain explicitly deferred a registration-order integration test because the test bootstrap needs a new accessor.
Diagram
sequenceDiagram participant Jetty participant Cleanup as PerRequestContextCleanupFilter participant Handler as Application handler participant Loader as Token loader Jetty->>Cleanup: Request Cleanup->>Cleanup: Clear request state Cleanup->>Handler: Continue request opt Load tokens Handler->>Loader: Read current tokens Loader->>Loader: Enter FreshReadScope Loader->>Loader: Read user with an empty request cache Loader->>Loader: Close scope Loader-->>Handler: Tokens end Handler-->>Cleanup: Return or throw Cleanup->>Cleanup: Clear request state in finallyReviews (1) · Last reviewed commit: "user token cache test" · Reviewed by Greptile