fix(mcp): bundle surfaces received keys on missing-arg errors (#357)#362
Merged
Conversation
Adds two tests under issue-357:
1. Pin the existing nested-args bundle path — verifies a bundle with
{tool, arguments: {path}} preserves path correctly. Passes today;
serves as a regression guard against future bundle arg-marshalling
regressions.
2. Failing test for the diagnostic improvement: when a bundle op fails
with 'missing path argument', the bundle wrapper should append the
keys actually received in that op so callers can tell whether
codedb dropped the arg or the client sent it under the wrong name
(e.g. file_path instead of path).
The second test fails on main — 'received keys' diagnostic is not
implemented yet. This is the actionable fix #357 actually asks for in
its 'Expected behavior' section.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Issue #357 reported repeated 'missing path argument' errors from bundled codedb_outline calls, suspecting that codedb_bundle was dropping nested arguments. Direct MCP probes and a Sonnet 4.6 agent reproducer both confirm bundled args are preserved correctly through both supported formats: {"tool": "codedb_outline", "arguments": {"path": "..."}} # nested {"tool": "codedb_outline", "path": "..."} # inline The error fires only when the bundle op genuinely lacks a 'path' key — e.g. agent sends 'file_path' instead of 'path', or omits args entirely. From the user-visible side it's indistinguishable from "codedb dropped path", which is why the issue was filed. This matches the issue's "Expected behavior" #2 (machine-readable diagnostics for malformed ops): when a bundled op fails with 'error: missing ...', the bundle wrapper now appends a 'received keys: [...]' line listing the keys actually present in that op. Callers can immediately tell whether the field was dropped by codedb or sent under the wrong name. Example output for a malformed op: --- [0] codedb_outline --- error: missing 'path' argument received keys: [tool, arguments] Fix: src/mcp.zig - new helper appendBundleArgKeysDiagnostic - handleBundle calls it when sub_out starts with "error: missing" Tests: src/tests.zig - issue-357: bundle preserves nested 'arguments' for codedb_outline (regression pin — passes today, guards against future regressions) - issue-357: bundle surfaces received keys when an op is missing required path (failing on main, passes with this fix) E2E coverage: scripts/test_issue_357_bundle_diagnostic.py Drives the real MCP over JSON-RPC stdio with all four shapes (nested ok, inline ok, wrong-key fail+diagnostic, no-args fail+diagnostic). 11/11 pass against the built binary. Closes #357 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Benchmark Regression ReportThresholds: 10.00% and 50,000 ns absolute delta
|
This was referenced May 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #357.
The issue reports repeated
error: missing 'path' argumentfrom bundledcodedb_outlinecalls and suspectscodedb_bundleis dropping nested arguments. It isn't — verified two ways:arguments: {path: "..."}and inline{tool, path: "..."}both work. The error fires only when the op genuinely lackspath(wrong key likefile_path, or no args at all).From the user's side it's indistinguishable from "codedb dropped path", which is why this issue was filed. The issue's "Expected behavior" actually allows a second resolution: machine-readable diagnostics on malformed ops. That's what this PR ships.
Change
When a bundled op fails with
error: missing ..., the bundle wrapper now appends areceived keys: [...]line listing the keys actually present in that op. Callers can immediately tell whether codedb dropped the field or the client sent it under the wrong name.Before
After
When the agent sent
file_pathby mistake:Implementation
appendBundleArgKeysDiagnosticinsrc/mcp.zig.handleBundlecalls it whensub_out.itemsstarts witherror: missing.sub_argsmap (which is whichever side of the nested/inline format the bundle resolved) and writes the keys.Test coverage
src/tests.zig:issue-357: bundle preserves nested 'arguments' for codedb_outline— regression pin. Passes today; guards against future arg-marshalling regressions.issue-357: bundle surfaces received keys when an op is missing required path— the actual MCP bundle should preserve nested tool arguments for codedb_outline #357 fix. Failing onmain, passes with this PR.scripts/test_issue_357_bundle_diagnostic.py— E2E driver against real JSON-RPC stdio. 11/11 pass against the freshly-built binary. Covers all four shapes (nested ok, inline ok, wrong-key fail+diagnostic, no-args fail+diagnostic).Test plan
zig build test— 423/423 passpython3 scripts/test_issue_357_bundle_diagnostic.py— 11/11 passerror: missingpath)🤖 Generated with Claude Code