Skip to content

Retry a failed initial trust anchor JWKS poll instead of failing - #215

Open
topperge wants to merge 2 commits into
go-oidfed:mainfrom
topperge:fix/ta-jwks-initial-poll
Open

topperge wants to merge 2 commits into
go-oidfed:mainfrom
topperge:fix/ta-jwks-initial-poll

Conversation

@topperge

Copy link
Copy Markdown
Contributor

Fixes #214.

A failed initial poll of a trust anchor with EnableJWKSUpdate no longer fails TAJWKSRefresher.Start or Add (and so Update):

  • Start and Add share a new startPolling. It runs the initial poll and, if the poll fails, logs a warning and starts the polling goroutine anyway, with a first wait of initialBackoff. The backoff then doubles up to maxBackoff as before.
  • pollGoroutine takes that first wait as a parameter.
  • The trust anchor keeps its current (pinned or stored) JWKS until a poll succeeds.
  • Start no longer stops at the first unreachable trust anchor, so it can't leave the refresher half-started.
  • Start still returns the "no JWKS available" error when a trust anchor has no JWKS and there is no storage to seed one.

Tests (ta_jwks_refresher_test.go):

  • Start with an unreachable trust anchor and storage succeeds (this updates TestTAJWKSRefresher_FirstPollSeedValidation, which asserted the old error);
  • Add of an unreachable trust anchor succeeds and keeps its JWKS;
  • a trust anchor whose initial poll fails is polled again after the backoff and keeps its JWKS (httpmock responder that always answers 503).

The new tests fail on main and pass with this change; go test ./... passes.

Like #212 and #213, this adds a changelog entry under a new "Unreleased" heading; please merge or move it as you prefer.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QYDqsx3UGxpCKvCiUxShZq

TAJWKSRefresher.Start and Add polled each trust anchor with
EnableJWKSUpdate once before starting its polling goroutine, and
returned an error when that poll failed: the trust anchor was never
polled, and Start stopped at the first one, leaving the refresher
half-started. A trust anchor that is briefly unreachable (restarting,
or not serving yet when this entity starts) thus stopped callers that
treat Start errors as fatal, or was left unpolled.

Start and Add now share startPolling, which logs a failed initial poll
as a warning and starts the goroutine with a first wait of
initialBackoff; the trust anchor keeps its current JWKS meanwhile.
Start still fails when a trust anchor has no JWKS and no storage to
seed it.

Fixes go-oidfed#214

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QYDqsx3UGxpCKvCiUxShZq
@deepsource-io

deepsource-io Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

DeepSource Code Review

We reviewed changes in be2f2ed...d8fa71b on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
Go Nov 12, 2026 9:02a.m. Review ↗
Code coverage Nov 12, 2026 9:33a.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

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.

TAJWKSRefresher: a failed initial poll makes Start/Add fail and leaves the trust anchor unpolled

2 participants