Skip to content

feat(mcp): Migrate to span first

7c5534e
Select commit
Loading
Failed to load commit list.
Merged

feat(mcp): Migrate to span first #6131

feat(mcp): Migrate to span first
7c5534e
Select commit
Loading
Failed to load commit list.
@sentry/warden / warden: code-review completed Apr 23, 2026 in 6m 15s

2 issues

code-review: Found 2 issues (1 high, 1 low)

High

Duplicate function definition for _set_span_data_attribute - `sentry_sdk/ai/utils.py:505-511`

The function _set_span_data_attribute is defined twice in this file - once at lines 505-511 and again at lines 514-520. In Python, the second definition silently overrides the first. While both definitions appear identical in this case, duplicate function definitions are a code smell and indicate a copy-paste error during the PR. This will work at runtime but creates maintenance confusion and suggests unintended code duplication.

Low

Non-streaming path in test_resource_handler_with_error lacks span status assertion - `tests/integrations/mcp/test_mcp.py:919-936`

The span streaming path asserts span["status"] == "error" and checks SPANDATA.MCP_TOOL_RESULT_IS_ERROR not in span["attributes"] (lines 917-918), but the non-streaming path (lines 919-936) only verifies the error event payload without asserting on the span's error status. This asymmetry means the non-streaming path has less test coverage for verifying that errors properly propagate to the span status.


Duration: 6m 11s · Tokens: 2.0M in / 21.3k out · Cost: $3.37 (+extraction: $0.00, +merge: $0.00, +fix_gate: $0.00)

Annotations

Check failure on line 511 in sentry_sdk/ai/utils.py

See this annotation in the file changed.

@sentry-warden sentry-warden / warden: code-review

Duplicate function definition for _set_span_data_attribute

The function `_set_span_data_attribute` is defined twice in this file - once at lines 505-511 and again at lines 514-520. In Python, the second definition silently overrides the first. While both definitions appear identical in this case, duplicate function definitions are a code smell and indicate a copy-paste error during the PR. This will work at runtime but creates maintenance confusion and suggests unintended code duplication.