Skip to content

Commit ca90834

Browse files
ericapisaniclaude
andcommitted
test(mcp): Assert span status in non-streaming error paths
The non-streaming branches of test_prompt_handler_with_error and test_resource_handler_with_error only verified error-event fields, leaving span status and transaction shape unchecked. Mirror the streaming-branch assertions and the tool-handler test pattern so regressions in classic-mode error handling for prompts and resources are caught. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 2b6fb52 commit ca90834

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

tests/integrations/mcp/test_mcp.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,14 @@ async def failing_prompt(name, arguments):
707707
assert error_event["level"] == "error"
708708
assert error_event["exception"]["values"][0]["type"] == "RuntimeError"
709709

710+
# Check transaction and span
711+
assert tx["type"] == "transaction"
712+
assert len(tx["spans"]) == 1
713+
span = tx["spans"][0]
714+
715+
assert span["status"] == "internal_error"
716+
assert SPANDATA.MCP_TOOL_RESULT_IS_ERROR not in span["data"]
717+
710718

711719
@pytest.mark.asyncio
712720
@pytest.mark.parametrize("span_streaming", [True, False])
@@ -935,6 +943,14 @@ def failing_resource(uri):
935943
assert error_event["level"] == "error"
936944
assert error_event["exception"]["values"][0]["type"] == "FileNotFoundError"
937945

946+
# Check transaction and span
947+
assert tx["type"] == "transaction"
948+
assert len(tx["spans"]) == 1
949+
span = tx["spans"][0]
950+
951+
assert span["status"] == "internal_error"
952+
assert SPANDATA.MCP_TOOL_RESULT_IS_ERROR not in span["data"]
953+
938954

939955
@pytest.mark.asyncio
940956
@pytest.mark.parametrize("span_streaming", [True, False])

0 commit comments

Comments
 (0)