Conversation
Test Failure Analysis
Summary: 2 tests in Root Cause: This PR only changes Suggested Solution: The failing tests should mock the token exchange call so they do not depend on network connectivity. In each test, patch from unittest.mock import AsyncMock, patch
with patch(
"fastmcp.server.auth.oauth_proxy.proxy.AsyncOAuth2Client.fetch_token",
new_callable=AsyncMock,
side_effect=Exception("mocked: token exchange unavailable"),
):
r = c.get(f"/auth/callback?code=fake&state={txn_id}", follow_redirects=False)
assert r.status_code != 403 # still passes — failure is 500, not 403This should be fixed in a separate PR that targets Detailed AnalysisFailing tests (Python 3.10 only): Deadlock stack trace (test client waiting indefinitely for app response): Root path through the code: Both tests reach # proxy.py:1712 — with HTTP_TIMEOUT_SECONDS = 30
oauth_client = AsyncOAuth2Client(timeout=HTTP_TIMEOUT_SECONDS, ...)
idp_tokens = await oauth_client.fetch_token(url="https://github.com/login/oauth/access_token", ...)The callback comment in the test says "It will fail at token exchange (500) but not at consent verification" — expecting a fast network error. In the Python 3.10 runner the connection attempt to GitHub hangs instead, exceeding the 5-second pytest limit. Why Python 3.13 passes: The CI annotation confirms GitHub is unreachable ( Related Files
🤖 Generated with Claude Code |
|
Auto-reviewed: all CI checks green, review comments addressed. Merging. |
Motivation
get_cached_typeadapterresolved forward/Annotated hints it rebuilt the callable withtypes.FunctionTypebut only copied positional defaults, causing__kwdefaults__to be lost and keyword-only parameters with defaults to become required in generated schemas and validation.Description
__kwdefaults__from the original callable (for both functions and bound methods) during the cloning path inget_cached_typeadapterand assign it to the rebuilt function vianew_func.__kwdefaults__insrc/fastmcp/utilities/types.py.TypeAdapterproduces the same schema/validation semantics as the original function.test_kwonly_defaults_preserved_when_annotations_are_processedtotests/utilities/test_types.pythat verifies schemadefaultand validation for a kw-onlyAnnotatedparameter.Testing
uv syncwhich completed successfully in this environment.uv run pytest -n auto, which exercises repository tests but reported unrelated timeouts/failures in this environment (13 failed, 1 error) that are not caused by this focused fix.uv run pytest tests/utilities/test_types.py -k kwonly_defaults_preserved_when_annotations_are_processedwhich passed and confirmed the regression is fixed.uv run pytest tests/utilities/test_typeadapter.pyanduv run ruff check src/fastmcp/utilities/types.py tests/utilities/test_types.pywhich both passed;uv run prek run --all-filesfailed due to an external pre-commit hook network fetch error unrelated to the code change.Codex Task