The retry landed in 9a232ad but was tested only through startupretry with
fake funcs; nothing exercised chassisauth.NewJWTValidator's real 502 path.
Extracts the main() closure into buildJWTValidator (behaviour unchanged)
and tests it against an httptest issuer: 3x502 then 200 succeeds with 4
discoveries; a persistent 502 stops at exactly the 8-attempt budget with
the last error; cancelling ctx mid-backoff returns context.Canceled.
Flip-verified: Attempts=1 turns all three red.
Lane: risk/medium issue, committed to main because the behaviour change
already shipped in 9a232ad; this is a test plus a pure extraction.
Closes #83
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
26 lines
802 B
Go
26 lines
802 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"log/slog"
|
|
|
|
chassisauth "git.d-ma.be/mathias/mcp-chassis/auth"
|
|
|
|
"github.com/mathiasbq/hyperguild/ingestion/internal/startupretry"
|
|
)
|
|
|
|
// buildJWTValidator runs OIDC discovery under policy, so a 502 from an auth
|
|
// upstream that is not serving yet on a cold boot is retried instead of
|
|
// exiting (#83). It honours ctx between attempts.
|
|
func buildJWTValidator(
|
|
ctx context.Context, logger *slog.Logger, issuer, audience string, policy startupretry.Policy,
|
|
) (*chassisauth.JWTValidator, error) {
|
|
return startupretry.Do(ctx, policy, func(ctx context.Context) (*chassisauth.JWTValidator, error) {
|
|
v, err := chassisauth.NewJWTValidator(ctx, issuer, audience)
|
|
if err != nil {
|
|
logger.Warn("oidc discovery not ready, retrying", "err", err)
|
|
}
|
|
return v, err
|
|
})
|
|
}
|