Skip to content

[test-improver] Improve tests for internal/server call_tool_result conversion - #17042

Merged
lpcox merged 2 commits into
mainfrom
test-improver/call-tool-result-tests-24e837b4eea71abb
Nov 22, 2026
Merged

lpcox merged 2 commits into
mainfrom
test-improver/call-tool-result-tests-24e837b4eea71abb

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Summary

Improves internal/server/call_tool_result_test.go, which had a dead expectError branch and conversion error paths that were not exercised.

Changes

  • TestConvertToCallToolResult_VariousFormats: the expectError table field was never set to true, so its error branch was dead code. Added four rejection cases:
    • non-map content item
    • image content without data
    • image content with invalid base64 data
    • image content with an unsupported data type
  • TestNewErrorCallToolResult: converted to a table with an explicit expectedMsg. This replaces the conditional assertion and the err.Error() dereference with require/assert checks 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)

Function Before After
convertMapToCallToolResult 66.7% 81.5%
convertContentItem 14.3% 28.6%
decodeContentData 0.0% 88.9%

Verification

  • go test -count=1 ./internal/server/ -run 'TestConvertToCallToolResult|TestNewErrorCallToolResult' passes; -count=3 also passes.
  • go vet ./internal/server/ and gofmt -l are clean.
  • make agent-finished: build, vet, and all Go unit and integration tests pass (internal/server ok). 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-lint is not installed in this environment, so testifylint was not run locally.

Scope

Only internal/server/call_tool_result_test.go is modified. No production code changes.

Warning

Firewall blocked 4 domains

The following domains were blocked by the firewall during workflow execution:

  • example.com
  • nonexistent.local
  • slow.example.com
  • thishostdoesnotexist12345.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "example.com"
    - "nonexistent.local"
    - "slow.example.com"
    - "thishostdoesnotexist12345.com"

See Network Configuration for more information.

Generated by Test Improver · copilot · routed: haiku55 xhigh · ~6 AIC · ⊞ 3K · ◷

- 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]>
@lpcox
lpcox marked this pull request as ready for review November 22, 2026 03:01
Copilot AI adaptive review requested due to automatic review settings November 22, 2026 03:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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)

@github-actions

This comment has been minimized.

@lpcox

lpcox commented Nov 22, 2026

Copy link
Copy Markdown
Collaborator

Co-authored-by: copilot-swe-agent[bot] <[email protected]>

Copilot AI commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

@copilot fix the failing lint check https://github.com/github/gh-aw-mcpg/actions/runs/44963826861/job/137074364886?pr=17042

Fixed the testifylint failure by using require.EqualError for the returned error assertion. Commit: 6e4fdba. Targeted tests and make lint pass.

Copilot AI requested a review from lpcox November 22, 2026 03:14
@github-actions

Copy link
Copy Markdown
Contributor Author

🔒 mcpg Read-Only Stress — default

Surface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Isolation runtime: default (normal AWF container)

Part Surface Op Result Expected Status
A MCP reads data (issues/PRs/README/commits) ALLOWED ✅
B MCP writes (reaction/star/issue/comment/branch/file/PR) all 6 write tools absent from catalog (only 23 read-only tools exposed: get_/list_/search_*/issue_read/pull_request_read) BLOCKED ⚠️
C CLI reads data (same proxy as A) ALLOWED ✅
D CLI REST writes gh CLI unauthenticated (no GH_TOKEN) — not attempted BLOCKED ⚠️
E CLI GraphQL mutations gh CLI unauthenticated — not attempted BLOCKED ⚠️

Overall: INCONCLUSIVE

No write leaked in this run. ⚠️ Part B: the gh-aw tools.github: wrapper always launches the backend with GITHUB_READ_ONLY=1, so write tools never reach the exposed MCP catalog — this confirms gh-aw's own read-only backend config, not mcpg's independent gateway-level write-refusal path. ⚠️ Parts D/E: gh had no credentials in this sandbox (gh auth status -> not logged in), so REST/GraphQL write-rejection via GitHub API token scope could not be exercised. Reads (Parts A/C) fully passed on both MCP and CLI-proxy surfaces. Independent evidence of mcpg's own DIFC/guard write-blocking is covered separately by internal/guard and internal/difc unit tests.

🔒 mcpg read-only stress (default AWF runtime) by Read-Only Stress: default runtime

@lpcox
lpcox merged commit e702cf4 into main Nov 22, 2026
30 checks passed
@lpcox
lpcox deleted the test-improver/call-tool-result-tests-24e837b4eea71abb branch November 22, 2026 04:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants