fastmcp/tests/client
Bill Easton d6b55c0b2f
Raise on unhandled content types in sampling handler dispatch chains (#3857)
* Raise on unhandled content types in sampling handler dispatch chains

The Anthropic and OpenAI sampling handlers have isinstance chains that
dispatch on MCP content types but silently drop unhandled variants like
EmbeddedResource and ResourceLink. This adds explicit else-raise guards
to match the Gemini handler's behavior and the single-content dispatch
paths that already raise.

Raising is the right choice over warn-and-skip: a partial conversion
produces a plausible-but-wrong LLM response (the model confidently
answers based on incomplete input), which is worse than a clear error
that tells the user exactly what isn't supported.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Add tests for unsupported content type raises in sampling handlers

Tests the new ValueError raises for unsupported content types
(e.g. EmbeddedResource) in the Anthropic and OpenAI message
conversion loops. Uses model_construct to bypass Pydantic's
union validation since the raise is a defensive guard for
future SDK content types.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 12:52:31 -04:00
..
auth fix: store absolute token expiry to prevent stale expires_in on reload (#3572) 2026-03-21 12:12:50 -04:00
client Harden client tool result error handling (#3778) 2026-04-08 13:57:10 -04:00
sampling Raise on unhandled content types in sampling handler dispatch chains (#3857) 2026-04-12 12:52:31 -04:00
tasks Expose minimum_check_interval, reduce task pickup latency (#3500) 2026-03-14 16:08:28 -04:00
telemetry Fix ty 0.0.17 diagnostics and bump lockfile 2026-02-16 16:13:38 -05:00
transports fix: bump ty to >=0.0.29 and suppress new false positives (#3790) 2026-04-07 19:49:09 -04:00
__init__.py clean up test inits 2025-05-31 19:32:08 -04:00
test_elicitation.py Update ty ignore comments for 0.0.25 compatibility (#3614) 2026-03-24 20:26:26 -04:00
test_elicitation_enums.py Update ty ignore comments for 0.0.25 compatibility (#3614) 2026-03-24 20:26:26 -04:00
test_logs.py Update ty ignore comments for 0.0.25 compatibility (#3614) 2026-03-24 20:26:26 -04:00
test_notifications.py Remove sync notification infrastructure 2026-01-18 17:31:11 -05:00
test_oauth_callback_race.py Guard OAuth callback result from post-completion overwrites (#3417) 2026-03-07 11:41:00 -05:00
test_oauth_callback_xss.py Escape all HTML to prevent XSS attack (#2090) 2025-10-14 12:30:21 -07:00
test_openapi.py Move OpenAPI to providers/openapi submodule (#2672) 2025-12-22 11:13:33 -05:00
test_progress.py Guard default progress handler against zero totals (#3432) 2026-03-07 11:41:11 -05:00
test_roots.py Add structured content & update almost all tests 2025-06-27 15:40:52 -04:00
test_sampling.py Split large test files to comply with loq line limit (#3328) 2026-02-28 11:21:11 -05:00
test_sampling_result_types.py fix: retry when LLM returns text instead of calling final_response (#3850) 2026-04-12 12:52:16 -04:00
test_sampling_tool_loop.py Split large test files to comply with loq line limit (#3328) 2026-02-28 11:21:11 -05:00
test_sse.py Bump tool sleep to actually validate timeout precedence 2026-03-02 13:50:29 -05:00
test_stdio.py fix: recover StdioTransport after subprocess exits (#3630) 2026-03-26 22:16:54 -04:00
test_streamable_http.py Fix ty 0.0.17 diagnostics and bump lockfile 2026-02-16 16:13:38 -05:00