Skip to content

fix(jwks): handle PyJWKSet returned from cache in get_jwk_set#1160

Open
armorbreak001 wants to merge 1 commit into
jpadilla:masterfrom
armorbreak001:fix/jwks-cache-pyjwkset-return
Open

fix(jwks): handle PyJWKSet returned from cache in get_jwk_set#1160
armorbreak001 wants to merge 1 commit into
jpadilla:masterfrom
armorbreak001:fix/jwks-cache-pyjwkset-return

Conversation

@armorbreak001

Copy link
Copy Markdown

When the JWK set cache is populated externally with a PyJWKSet instance (e.g. from a pre-fetched JWKS stored externally), get_jwk_set() raised PyJWKClientError because it only expected dict or None from the cache.

The isinstance(data, dict) guard correctly validates fresh fetch results (which are dicts from JSON), but fails when the cache contains a PyJWKSet put there by user code — which is what the type hints for JWKSetCache.put() suggest is the intended usage.

Before this fix:

PyJWKClientError: The JWKS endpoint did not return a JSON object

Fix: Return cached PyJWKSet objects directly, before the dict type check.

Fixes #914

When the JWK set cache is populated externally with a PyJWKSet
instance (e.g. from a pre-fetched JWKS), get_jwk_set() raised
PyJWKClientError because it expected only dict or None from the
cache. Return cached PyJWKSet objects directly.

Fixes jpadilla#914
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.

The JWKS endpoint did not return a JSON object when keys are found in the cache

1 participant