Handle non-fatal httprc errors in JWKS registration - #6221
Merged
Conversation
danbarr
requested review from
ChrisJBurns,
JAORMX,
jhrozek,
rdimitrov and
tgrunnagle
as code owners
August 6, 2026 00:58
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6221 +/- ##
==========================================
+ Coverage 72.47% 72.50% +0.02%
==========================================
Files 739 739
Lines 76719 76728 +9
==========================================
+ Hits 55600 55628 +28
+ Misses 17152 17121 -31
- Partials 3967 3979 +12 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
reyortiz3
approved these changes
Aug 6, 2026
stack merge was automatically disabled
August 6, 2026 02:01
Pull Request is not mergeable
danbarr
force-pushed
the
fix-jwks-errnotready
branch
from
August 6, 2026 02:04
2701a9b to
b734433
Compare
ensureJWKSRegistered treated every Register error as fatal and left jwksRegistered unset so the next call retries. But httprc returns ErrNotReady when the resource was successfully registered and only the first fetch has not completed; the resource is already in httprc's map, so every retry then fails with ErrResourceAlreadyExists. One slow or failed first fetch permanently disabled the validator for the life of the process. Treat ErrNotReady as registered-but-pending so Lookup surfaces a not-ready key set until a background fetch succeeds, and treat ErrResourceAlreadyExists as already-registered. The latter also covers OIDC re-discovery resolving to the same JWKS URL after the registration flag is reset. Fixes #6218 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
danbarr
force-pushed
the
fix-jwks-errnotready
branch
from
August 6, 2026 02:05
b734433 to
e5fe29f
Compare
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.
Summary
ensureJWKSRegisteredtreats everyRegistererror as fatal and leaves the registration flag unset for retry. But httprc returnsErrNotReadywhen the resource was successfully registered and only the first fetch hasn't completed; the resource is already in httprc's map, so every retry then fails withErrResourceAlreadyExists. One slow or failed first JWKS fetch (a slow IdP, a network blip on the first authenticated request, or the client bypass fixed in #6220) permanently disabled token validation for the life of the process.ErrNotReadyas registered-but-pending: the validator proceeds andLookupsurfaces a not-ready key set until a background fetch succeeds, so transient first-fetch failures now self-heal.ErrResourceAlreadyExistsas already-registered. Besides being the escape hatch for the retry trap, this also covers OIDC re-discovery resolving to the same JWKS URL after the registration flag is reset.Fixes #6218
Type of change
Test plan
pkg/auth/...with race detection; new tests verified to fail pre-fix)task lintpassesDoes this introduce a user-facing change?
Transient failures fetching an external OIDC issuer's JWKS on first use no longer permanently disable token validation until restart; validation recovers once a background fetch succeeds.
Special notes for reviewers
Stacked on #6220, which fixed the trigger that surfaced this; this PR hardens the retry path against any first-fetch failure. Review only this layer's diff via the stacked PR view.
Generated with Claude Code