fix(mcp): ignore malformed path-like text#4456
Merged
WillemJiang merged 1 commit intoJul 25, 2026
Merged
Conversation
Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>
WillemJiang
approved these changes
Jul 25, 2026
yangjl
pushed a commit
to yangjl/deer-greenagent
that referenced
this pull request
Jul 26, 2026
Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>
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.
Why
MCP tool results can include free-text file paths that are parsed by DeerFlow so local stdio MCP outputs can be rewritten into
/mnt/user-data/...virtual artifact paths. That rewrite is intentionally best-effort: text that is not a real resolvable local file should be left untouched.A malformed path-like token such as:
breaks that contract today. The free-text path regex captures
//[::1/foo.png,_local_path_from_uri()passes it directly tourllib.parse.urlparse(), and Python raises:That exception bubbles through
_rewrite_local_paths_in_text()and_convert_call_tool_result(), so one malformed provider/server text result can fail the whole MCP tool result conversion instead of being ignored as an unresolvable local path candidate.Call chain:
What changed
_local_path_from_uri()now treatsurlparse()ValueErrors the same way it treats remote, missing, relative-without-base, or otherwise non-local candidates: returnNone.CallToolResultconversion boundary.This does not broaden what gets rewritten. Valid local paths, valid
file://URIs, remote URLs, missing files, and existing virtual path behavior stay unchanged.Surface area
frontend/backend/appbackend/packages/harness/deerflow/mcpdocker/or sandboxed executionskills/backend/pyproject.tomlorfrontend/package.json(say what it buys us)Screenshots / Recording
N/A. This is a backend MCP result-normalization fix with command-line reproduction and unit coverage.
Bug fix verification
backend/tests/test_mcp_file_migration.py::TestLocalPathFromUri::test_malformed_uri_is_ignoredbackend/tests/test_mcp_file_migration.py::TestRewriteLocalPathsInText::test_malformed_path_like_text_is_left_untouchedbackend/tests/test_mcp_file_migration.py::TestConvertCallToolResultRewrites::test_malformed_path_like_text_result_does_not_raisemainand green on this branch? Yes for the same behavior. A focused pre-fix reproduction raisedValueError: Invalid IPv6 URL; after the fix, the same payload returns a text block with the original text unchanged.Focused reproduction:
Before the fix, this raised from
urlparse():After the fix, it returns the text unchanged:
Validation
uv run --project backend pytest backend/tests/test_mcp_file_migration.py::TestLocalPathFromUri::test_malformed_uri_is_ignored backend/tests/test_mcp_file_migration.py::TestRewriteLocalPathsInText::test_malformed_path_like_text_is_left_untouched backend/tests/test_mcp_file_migration.py::TestConvertCallToolResultRewrites::test_malformed_path_like_text_result_does_not_raise- passed, 3 tests.uv run --project backend python -c "...malformed //[::1/foo.png reproduction..."- passed after the fix; returned unchanged text content.uv run --project backend ruff check backend/packages/harness/deerflow/mcp/tools.py backend/tests/test_mcp_file_migration.py- passed.uv run --project backend ruff format --check backend/packages/harness/deerflow/mcp/tools.py backend/tests/test_mcp_file_migration.py- passed.git diff --check- passed.uv run --project backend pytest backend/tests/test_mcp_file_migration.pyon Windows reported existing POSIX path expectation failures unrelated to this patch (15 failed, 43 passed, 1 skipped). The three new malformed-URI regressions passed in the focused run.backend/.venvon the mountedD:drive by an environment copy I/O error before tests executed.AI assistance
Tool(s) used: Codex
How you used it: Codex inspected the MCP result conversion path, reproduced the malformed URI failure, implemented the small guard, added regression tests, and ran focused validation. I reviewed the final diff and validation output.