Skip to content

ResourceWarning on Python 3.14 when HTTP errors returned #1128

@alichaudry

Description

@alichaudry

PyJWKClient causes ResourceWarning on Python 3.14 when JWKS endpoint returns HTTP errors.

Expected Result

When PyJWKClient.fetch_data() encounters an HTTP error (e.g., 401 Unauthorized), the request should be cleanly handled without resource warnings.

Actual Result

On Python 3.14, a ResourceWarning is raised during garbage collection:

ResourceWarning: Implicitly cleaning up <HTTPError 401: 'Unauthorized'>

Reproduction Steps

import jwt
import warnings

warnings.filterwarnings('default')

client = jwt.PyJWKClient("https://dev-example.us.auth0.com/.well-known/jwks.json")
try:
    client.get_signing_keys()
except jwt.PyJWKClientConnectionError:
    pass

# output:
# python3.14/tempfile.py:484: ResourceWarning: Implicitly cleaning up <HTTPError 404: 'Not Found'>
#   _warnings.warn(self.warn_message, ResourceWarning)

System Information

$ python -m jwt.help
{
  "cryptography": {
    "version": "46.0.3"
  },
  "implementation": {
    "name": "CPython",
    "version": "3.14.2"
  },
  "platform": {
    "release": "25.2.0",
    "system": "Darwin"
  },
  "pyjwt": {
    "version": "2.10.1"
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions