Repository navigation
[test-improver] Improve tests for internal/server call_tool_result conversion - #17042
Conversation
- Make the expectError table field in TestConvertToCallToolResult_VariousFormats effective by adding rejection cases: non-map content item, image content without data, invalid base64 image data, and unsupported data type. - Convert TestNewErrorCallToolResult to a table with an explicit expectedMsg, replacing the conditional assertions and err.Error() dereference with require/assert checks on the returned error and content text. Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
🟢 Approval recommended
The review identifies no active issues, and the changes add focused server-level coverage for malformed inputs and explicit error-result behavior without modifying production code.
No open issues 🎉
What changed in this PR
This pull request strengthens server-level tests for MCP tool-result conversion by exercising previously untested error paths and making error-result assertions explicit.
Changes:
- Adds rejection cases for malformed content items and invalid image data.
- Reworks error-result tests to verify exact returned messages and content.
- No production code changes.
| File | Description |
|---|---|
| internal/server/call_tool_result_test.go | Adds malformed-input conversion cases and strengthens assertions for error CallToolResult construction. |
Review effort: Lite (adaptive)
This comment has been minimized.
This comment has been minimized.
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Fixed the |
🔒 mcpg Read-Only Stress — defaultSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE No write leaked in this run.
|
Summary
Improves
internal/server/call_tool_result_test.go, which had a deadexpectErrorbranch and conversion error paths that were not exercised.Changes
TestConvertToCallToolResult_VariousFormats: theexpectErrortable field was never set totrue, so its error branch was dead code. Added four rejection cases:datadatadatatypeTestNewErrorCallToolResult: converted to a table with an explicitexpectedMsg. This replaces the conditional assertion and theerr.Error()dereference withrequire/assertchecks on the returned error and content text. Behavior is unchanged for the three existing cases.Coverage (
internal/mcp/tool_result.go, measured via server tests)convertMapToCallToolResultconvertContentItemdecodeContentDataVerification
go test -count=1 ./internal/server/ -run 'TestConvertToCallToolResult|TestNewErrorCallToolResult'passes;-count=3also passes.go vet ./internal/server/andgofmt -lare clean.make agent-finished: build, vet, and all Go unit and integration tests pass (internal/serverok). The pipeline stops at the Rust guard step (test-rust), which cannot reach crates.io from the sandbox (SSL certificate mismatch). This is unrelated to this change.golangci-lintis not installed in this environment, so testifylint was not run locally.Scope
Only
internal/server/call_tool_result_test.gois modified. No production code changes.Warning
Firewall blocked 4 domains
The following domains were blocked by the firewall during workflow execution:
example.comnonexistent.localslow.example.comthishostdoesnotexist12345.comTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.