test: Remove manual transactions around MCP spans from the stdio transport - #6917
test: Remove manual transactions around MCP spans from the stdio transport#6917alexander-alderman-webb wants to merge 3 commits into
Conversation
Codecov Results 📊✅ 98557 passed | ❌ 1 failed | ⏭️ 6756 skipped | Total: 105314 | Pass Rate: 93.58% | Execution Time: 356m 1s 📊 Comparison with Base Branch
➕ New Tests (1)View new tests
❌ Failed Tests
|
| assert tx["contexts"]["trace"]["status"] == "internal_error" | ||
| assert tx["contexts"]["trace"]["status"] == "internal_error" |
There was a problem hiding this comment.
Duplicate assertion in test_tool_handler_error_stdio
The third assertion checking tx["contexts"]["trace"]["status"] is an exact duplicate of the line above it, meaning the original span["tags"]["status"] check was lost during refactoring and nothing new is verified.
Evidence
- In the original code, three distinct properties were asserted:
span["data"][...],span["status"], andspan["tags"]["status"]. - After the refactor to remove the manual transaction wrapper, the assertions were mapped to
tx["contexts"]["trace"]. assert tx["contexts"]["trace"]["status"] == "internal_error"appears on both lines 657 and 658, making the second one a no-op.- The duplicate was introduced because the original
span["tags"]["status"]assertion was incorrectly replaced, losing its intent. - The equivalent FastMCP test (
test_fastmcp.pylines 598-601) does not contain this duplicate assertion, confirming it is unintentional.
Identified by Warden · find-bugs · 2Z9-MNW
| assert SPANDATA.MCP_TOOL_RESULT_IS_ERROR not in span["data"] | ||
| assert tx["contexts"]["trace"]["status"] == "internal_error" | ||
| assert SPANDATA.MCP_TOOL_RESULT_IS_ERROR not in tx["contexts"]["trace"] | ||
|
|
There was a problem hiding this comment.
Resource error test checks wrong dict level for MCP_TOOL_RESULT_IS_ERROR
Assertion checks tx['contexts']['trace'] instead of tx['contexts']['trace']['data'], so it never validates the attribute is actually absent.
Evidence
- Old code checked
SPANDATA.MCP_TOOL_RESULT_IS_ERROR not in span['data']wherespanwas the nested MCP span. - After removing the manual transaction wrapper, the assertion was migrated to
tx['contexts']['trace']but omitted the['data']segment. - In the same file,
test_prompt_handler_with_error(line 970) correctly usestx['contexts']['trace']['data']for the identical check. tx['contexts']['trace']contains trace metadata keys (op, status, trace_id), not span attributes, so the assertion always trivially passes and cannot catch regressions.
Identified by Warden · find-bugs · VX5-C24
Description
Issues
Reminders
uv run ruff.feat:,fix:,ref:,meta:)