fix: structure MCP tool error envelopes - #1122
Conversation
📝 WalkthroughWalkthroughMCP error responses now contain nested ChangesMCP error response format
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/nmp_common/src/nmp/common/mcp/error_handling.py`:
- Around line 36-42: Update format_error_response in
packages/nmp_common/src/nmp/common/mcp/error_handling.py#L36-L42 to include
error.retryable, true only for ConnectionError or TimeoutError. Update the
canonical response example in
packages/nmp_common/src/nmp/common/mcp/README.md#L44-L48, align the
empty-message example with the fallback at
packages/nmp_common/src/nmp/common/mcp/README.md#L196-L203, and extend
packages/nmp_common/tests/mcp/test_error_handling.py#L11-L30 to assert both
retryable and non-retryable errors.
In `@services/core/mcp/tests/integration/smoke_test.py`:
- Around line 134-141: Update both controlled-error assertions in
services/core/mcp/tests/integration/smoke_test.py lines 134-141 and
services/core/entities/tests/integration/smoke_test_mcp.py lines 132-138 to
compare result["error"] against the exact expected structured error object for
RuntimeError("platform unavailable"), while retaining the success and error_type
assertions.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 9b164d0a-c211-473a-9608-a104c549ac92
📒 Files selected for processing (5)
packages/nmp_common/src/nmp/common/mcp/README.mdpackages/nmp_common/src/nmp/common/mcp/error_handling.pypackages/nmp_common/tests/mcp/test_error_handling.pyservices/core/entities/tests/integration/smoke_test_mcp.pyservices/core/mcp/tests/integration/smoke_test.py
NVBug: 6556550 Signed-off-by: Matt Kornfield <mkornfield@nvidia.com>
b8bf649 to
2e29794
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
♻️ Duplicate comments (1)
services/core/mcp/tests/integration/smoke_test.py (1)
134-141:⚠️ Potential issue | 🟡 MinorAssert the controlled error envelope exactly.
Both tests raise
RuntimeError("platform unavailable")and only check that the structured fields are non-empty. Compareresult["error"]with the exact expected object, including the documented default hint.
services/core/mcp/tests/integration/smoke_test.py#L134-L141: assert the exactRuntimeErrorerror object.services/core/entities/tests/integration/smoke_test_mcp.py#L132-L138: assert the same exact error object.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@services/core/mcp/tests/integration/smoke_test.py` around lines 134 - 141, Replace the non-empty field checks in the error-response assertions with an exact comparison against the documented structured error object for RuntimeError("platform unavailable"), including its stable code, message, and default hint. Apply the same assertion update in services/core/mcp/tests/integration/smoke_test.py lines 134-141 and services/core/entities/tests/integration/smoke_test_mcp.py lines 132-138.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Duplicate comments:
In `@services/core/mcp/tests/integration/smoke_test.py`:
- Around line 134-141: Replace the non-empty field checks in the error-response
assertions with an exact comparison against the documented structured error
object for RuntimeError("platform unavailable"), including its stable code,
message, and default hint. Apply the same assertion update in
services/core/mcp/tests/integration/smoke_test.py lines 134-141 and
services/core/entities/tests/integration/smoke_test_mcp.py lines 132-138.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 2594d50e-ed03-4f52-8d6a-3964c34b2a3b
📒 Files selected for processing (5)
packages/nmp_common/src/nmp/common/mcp/README.mdpackages/nmp_common/src/nmp/common/mcp/error_handling.pypackages/nmp_common/tests/mcp/test_error_handling.pyservices/core/entities/tests/integration/smoke_test_mcp.pyservices/core/mcp/tests/integration/smoke_test.py
🚧 Files skipped from review as they are similar to previous changes (3)
- packages/nmp_common/tests/mcp/test_error_handling.py
- packages/nmp_common/src/nmp/common/mcp/error_handling.py
- packages/nmp_common/src/nmp/common/mcp/README.md
|
Signed-off-by: Matt Kornfield <mkornfield@nvidia.com>
Summary
format_error_responseto return a nestederrorobject with stablecode,message, andhintfields.error_typeshape from the shared helper.NVBug
Validation
uv run --frozen pytest packages/nmp_common/tests/mcp/test_error_handling.py services/core/mcp/tests/integration/smoke_test.py::TestMCPServerSmoke::test_list_workspaces_error_handling services/core/entities/tests/integration/smoke_test_mcp.py::TestEntitiesMCPServerSmoke::test_list_workspaces_error_handling -q: 4 passeduv run --frozen ruff check ...on touched MCP filesuv run --frozen ty check ...on touched MCP filesSummary by CodeRabbit
New Features
Documentation
Bug Fixes
error_typefield from error responses.Review follow-up
4c66b6b05(fix: include retryable MCP error metadata).6 passed; targeted Ruff and ty checks passed.uv run pre-commit run -ais blocked by the samehelm-docshook fetch HTTP 503 noted on the related PR.