Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PyJWKSet reports the wrong exception for an empty key set #754

Closed
lbam opened this issue May 11, 2022 · 4 comments
Closed

PyJWKSet reports the wrong exception for an empty key set #754

lbam opened this issue May 11, 2022 · 4 comments

Comments

@lbam
Copy link

lbam commented May 11, 2022

Empty key sets give the wrong exception. The error is here:

pyjwt/jwt/api_jwk.py

Lines 80 to 84 in 24b29ad

if not keys or not isinstance(keys, list):
raise PyJWKSetError("Invalid JWK Set value")
if len(keys) == 0:
raise PyJWKSetError("The JWK Set did not contain any keys")

When keys is the empty list, not keys is true so the second check is never reached (unless some list subclass overrides __bool__).

Expected Result

Should raise PyJWKSetError("The JWK Set did not contain any keys").

Actual Result

Raises PyJWKSetError("Invalid JWK Set value").

Reproduction Steps

import jwt
jwt.PyJWKSet.from_dict({"keys": []})
@jpadilla
Copy link
Owner

probably fixed by #762

@lbam
Copy link
Author

lbam commented May 31, 2022

Not fixed. #762 changes code beyond the point where this exception occurs. Would you please reopen the issue?

@jpadilla jpadilla reopened this May 31, 2022
@github-actions
Copy link

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

@github-actions github-actions bot added the stale Issues without activity for more than 60 days label Jul 31, 2022
@jpadilla jpadilla removed the stale Issues without activity for more than 60 days label Jul 31, 2022
@auvipy auvipy closed this as completed Aug 1, 2022
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

No branches or pull requests

4 participants
@jpadilla @auvipy @lbam and others