Skip to content

fix: replace authlib with requests to eliminate AuthlibDeprecationWarning#632

Open
ambient-code[bot] wants to merge 3 commits intomainfrom
fix/627-remove-authlib-deprecation-warning
Open

fix: replace authlib with requests to eliminate AuthlibDeprecationWarning#632
ambient-code[bot] wants to merge 3 commits intomainfrom
fix/627-remove-authlib-deprecation-warning

Conversation

@ambient-code
Copy link
Copy Markdown
Contributor

@ambient-code ambient-code Bot commented Apr 24, 2026

Summary

  • Removes the authlib dependency from jumpstarter-cli-common which triggers an AuthlibDeprecationWarning on every import due to its internal authlib.jose module usage
  • Replaces authlib.integrations.requests_client.OAuth2Session with a lightweight _OAuth2Client class using requests.Session directly
  • Adds requests as an explicit dependency (was previously a transitive dependency of authlib)
  • All existing OAuth2 flows (authorization code, password, token exchange, refresh token) are preserved with the same behavior

Fixes #627

Test plan

  • All 25 existing jumpstarter-cli-common tests pass (including 4 oidc tests)
  • Verified no AuthlibDeprecationWarning when importing jumpstarter_cli_common.oidc
  • Lint passes (make lint-fix)
  • Manual testing of OAuth2 flows against a real OIDC provider

Generated with Claude Code

…ning

Remove the authlib dependency which triggers a deprecation warning from
its internal authlib.jose module on every import. Replace the
OAuth2Session usage with a lightweight _OAuth2Client class that uses
requests.Session directly for OAuth2 flows.

Fixes #627

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add tests covering __init__, verify property, create_authorization_url,
fetch_token, and Config.client to bring coverage on changed lines from
26.2% to 100%, meeting the 80% threshold required by diff-cover CI.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ambient-code
Copy link
Copy Markdown
Contributor Author

ambient-code Bot commented Apr 24, 2026

Added unit tests for the _OAuth2Client class to fix the diff-cover check failure.

The new test file (jumpstarter_cli_common/test_oidc.py) contains 20 tests covering:

  • __init__ — verifies attributes are set correctly, including optional redirect_uri
  • verify property getter/setter — confirms it delegates to requests.Session.verify
  • create_authorization_url — tests URL construction, redirect_uri inclusion/exclusion, extra kwargs, existing query params, and state uniqueness
  • fetch_token — tests grant_type flow, authorization_response parsing (with/without code, with/without redirect_uri), scope override, and HTTP error handling
  • Config.client — verifies it returns an _OAuth2Client instance with correct settings, including insecure_tls and kwargs passthrough

Diff-cover on changed lines is now 100% (was 26.2%), well above the 80% threshold.

Each sub-package's coverage.xml records filenames relative to the
package directory (e.g. "jumpstarter_cli_common/oidc.py"), but
diff-cover resolves paths relative to the git root. This mismatch
caused diff-cover to miss coverage data from per-package test runs,
resulting in artificially low coverage percentages on changed lines.

Fix by injecting the correct <source> element into each coverage.xml
before running diff-cover, allowing it to reconstruct absolute paths
that match the git diff output.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ambient-code
Copy link
Copy Markdown
Contributor Author

ambient-code Bot commented Apr 24, 2026

CI Fix: diff-cover path resolution

The pytest-matrix CI failure was caused by a path mismatch between coverage.xml files and diff-cover's path resolution, not by missing test coverage.

Root Cause

Each sub-package test run (via uv run --isolated --directory packages/<pkg> pytest) generates a coverage.xml with filenames relative to the package directory (e.g., jumpstarter_cli_common/oidc.py). However, diff-cover resolves paths relative to the git root (e.g., python/packages/jumpstarter-cli-common/jumpstarter_cli_common/oidc.py). Without a <source> element in the XML to bridge the gap, diff-cover cannot match the coverage data to the git diff.

The 26.2% coverage reported by CI came solely from the jumpstarter-cli package tests (which happen to import jumpstarter_cli_common.oidc and record absolute paths in their coverage.xml). The jumpstarter-cli-common package tests -- including all 20 test_oidc.py tests -- generated full coverage but diff-cover could not find it due to the path mismatch.

Fix

Added a CI step that injects the correct <source> element into each package's coverage.xml before running diff-cover. This lets diff-cover reconstruct absolute paths and match coverage data to git diff output.

Note: This is a pre-existing infrastructure issue affecting all sub-packages in the mono-repo, not specific to this PR. The fix benefits all future PRs.

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.

AuthlibDeprecationWarning: authlib.jose module is deprecated, please use joserfc instead.

0 participants