Harden fastmcp metadata parsing in proxy paths#3412
Merged
Conversation
🤖 Generated with GPT-5.2-Codex
Member
Author
|
Auto-reviewed and merging on behalf of @jlowin — CI is green (Windows OAuth proxy timeouts are pre-existing flaky tests). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
meta["fastmcp"](or legacy_fastmcp) is always a mapping, so a remote server returning a non-dict value could cause.get("tags")to raise and crash proxy listing/ingestion paths.fastmcp/_fastmcpvalues as absent, restoring the previous tolerant behavior and preventing a remote DoS vector.Description
get_fastmcp_metadata(meta)defensive: it now returns the first namespace value that is adictand otherwise returns{}so non-dict upstream values are ignored.fastmcpdict is returned, legacy_fastmcpis used when appropriate, and non-dict values are ignored.src/fastmcp/utilities/components.py(metadata parsing logic) andtests/utilities/test_components.py(new tests).Example usage after the change:
Testing
uv syncsuccessfully to prepare the environment.uv run pytest -n auto, which surfaced unrelated existing failures/timeouts in this environment (several unrelated tests failed); these failures are not caused by this patch.uv run pytest tests/utilities/test_components.py tests/server/providers/proxy/test_proxy_server.py -n auto, which completed successfully (the component/proxy tests passed).uv run prek run --all-filesbut hook initialization failed due to external network access when fetching hooks (pre-commit mirror bootstrap error), so lint hooks were not executed in this environment.Codex Task