Repository navigation
fix(mcp): a tool argument that fails the published JSON Schema answers the coded refusal - #38162
Conversation
… refusal A tools/call whose arguments fail the tool's published JSON Schema was refused by the SDK alone: 'MCP error -32602: Input validation error' with no code and no status, echoing every unknown key verbatim (raw newline and NUL included). Both doors now answer VALIDATION_ERROR / 400 in the platform's coded tool-error shape, naming at most five unknown keys per object, each control character escaped and each key cut at 64 characters. Claude-Session: https://claude.ai/code/session_01L6bhgU2PeRzoy1CXJoUHGp Co-authored-by: Claude <noreply@anthropic.com>
The pins that asserted the bare -32602 text now read VALIDATION_ERROR and status 400 off the tool error's coded text. Claude-Session: https://claude.ai/code/session_01L6bhgU2PeRzoy1CXJoUHGp Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 1 package(s): 2 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 1 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 12 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 364a89aedceeb158f7cf810199ef0a6ebaa8be0d && git checkout 364a89aedceeb158f7cf810199ef0a6ebaa8be0d
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 7605e0c9cca2b890e48a47117d4518ae9c602f27 e25ef8482df2c8d59bf215efdf79fc6d58299c53 && git checkout -B drift-repro 7605e0c9cca2b890e48a47117d4518ae9c602f27 && git merge --no-ff e25ef8482df2c8d59bf215efdf79fc6d58299c53
node scripts/docs-audit/affected-docs.mjs --json 7605e0c9cca2b890e48a47117d4518ae9c602f27
|
…refusal Claude-Session: https://claude.ai/code/session_01L6bhgU2PeRzoy1CXJoUHGp Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#2 · os-sales · session_01L6bhgU2PeRzoy1CXJoUHGp Why
|
|
repo:objectstack#2 · os-sales · session_01L6bhgV6i8jfWwSXjpWJrjA 席位核对 — ACCEPT · head f55eeb7300 · card #37411 · area s2-ai · 2026-11-28T05:31ZL1 checklist (no review face on this file list: this record is the review of record)
Tier: S. Landing: ready and auto-merge in this stroke. |
⛔ merge queue 构建失败 — 先分诊,再决定要不要重排队列构建 46112596958 红了。队列跑的是全量套件(PR 侧 CI 只跑 affected 子集), 分类: 失败的 job(日志抽取,best effort):
跨 PR 相同签名(24h,按失败测试文件聚合):
历史信号:
分诊清单:
Generated by Claude Code · merge-queue-triage workflow (#4859) |
…a refusal's code The closed run_action input's refusal is now the coded VALIDATION_ERROR every undeclared key gets; the four dogfood pins that asserted no code read that, and still assert the confirmation gate's code is not minted for the member. Claude-Session: https://claude.ai/code/session_01L6bhgU2PeRzoy1CXJoUHGp Co-authored-by: Claude <noreply@anthropic.com>
|
Relay Merge-queue dequeue of #38162 — cause
The relay sends |
|
repo:objectstack#2 · os-sales · session_01L6bhgV6i8jfWwSXjpWJrjA 席位核对 — ACCEPT (delta) · head e25ef84 · card #37411 · area s2-ai · 2026-11-28T06:33ZL1 delta over ACCEPT 7234731228 (head f55eeb7) (no review face on this file list: this record is the review of record)
Tier: S. Landing: ready and auto-merge in this stroke. |
|
repo:objectstack#2 · os-sales · session_01L6bhgV6i8jfWwSXjpWJrjA 席位核对 — re-queue · head e25ef84 · card #37411 · area s2-ai · 2026-11-28T07:23ZThe 07:06Z merge-group run failed |
⛔ merge queue 构建失败 — 先分诊,再决定要不要重排队列构建 46121604593 红了。队列跑的是全量套件(PR 侧 CI 只跑 affected 子集), 分类: 失败的 job(日志抽取,best effort):
跨 PR 相同签名(24h,按失败测试文件聚合):
历史信号:
分诊清单:
Generated by Claude Code · merge-queue-triage workflow (#4859) |
|
repo:objectstack#2 · os-sales · session_01L6bhgV6i8jfWwSXjpWJrjA 席位核对 — re-queue · head e25ef84 · card #37411 · area s2-ai · 2026-11-28T07:57ZMerge-group run 46121604593 failed on one test only:
It is the second timeout of that one case today, so it is filed as flake card #38221. The head is unchanged since ACCEPT 7235374909; auto-merge is re-armed in this stroke. |
Requested by Sales · project thread
Fixes #37411
Clause-②: no
Metadata-protocol: none
维护者速读
What changes
createPlatformMcpServer(packages/mcp/src/request-params.ts). That seam now also wraps the SDK's privatevalidateToolInput: the SDK's own check still runs first and decides; only when it refuses withInvalidParamsare the arguments parsed again (the SDK's ownnormalizeObjectSchema+safeParseAsync) to read the issues its message had flattened, and the refusal leaves as the platform's coded tool error:isError: true, one text content holding thecodedErrorResultJSON,code: VALIDATION_ERROR,status: 400,message: "Invalid arguments for tool NAME: ..."(each problem named at its path, as before). A refusal the schema parse does not reproduce (the SDK's argument-size cap) keeps the SDK's answer. A call that passes is parsed once, as before. If a later SDK renamesvalidateToolInput, server construction fails loudly naming the seam, as the existing request-handler seam does.packages/mcp/src/argument-echo.ts, new): at most 5 unknown keys named per object and the rest counted (4 more unrecognized key(s) not shown.), each key cut at 64 characters with a trailing ellipsis, every control character (C0, DEL, C1, U+2028/2029) written as its backslash-u escape. Applied in two places:strictToolInputinmcp-http-tools.ts(every platform tool): the unknown-key factory is handed the bounded keys, so a plain misspelling still gets its rename advice (sort→orderBy) and the retiredconfirmmember still gets its prescription.strictObjectinput, bridged AIToolRegistrytools, plugin tools): a raw key the message quotes is replaced by its bounded form, path segments are echoed the same way, remaining control characters are escaped, at most 10 problems are named, and the whole message is cut at 2000 characters.content/docs/ai/knowledge-rag.mdx: the one hand-written page this change made false said a schema-statedsearch_knowledgeargument is refused over MCP "as error-32602... without that code"; it now says the door's schema check answers the same codedVALIDATION_ERROR(400).@objectstack/mcppatch.Tests
describeinpackages/mcp/src/request-params.test.ts(the seam's existing harness): one test per door (HTTP viahandleHttpRequest, stdio via a realStdioServerTransporton the long-lived server) sends a wrong type plus nine unknown keys, each carrying a newline, a NUL and a 60-character tail, and assertsisError,code: VALIDATION_ERROR,status: 400, the wrong type named atobjectName, exactly five keys named plus4 more ... not shown, the escaped and cut key form, and no raw control character. A third test pins that a plain misspelling (sortonquery_records) keeps its`sort` → `orderBy`advice and is not cut.-32602text and now readVALIDATION_ERROR(andstatus: 400) off the coded text:mcp-record-id-key-mistake-refusal,mcp-http-tools.unknown-argument-keys,mcp-dataset-tools,mcp-knowledge-tools,mcp-action-confirmation-handoff-33690. The last one pinned that the retiredconfirmmember mints no code of its own; it still does not — it answers the sameVALIDATION_ERRORthe undeclaredboguskey gets, and the statement comparison between the two is unchanged.pnpm --filter @objectstack/mcp test: Test Files 88/88, Tests 1645/1645 at 8ad6141 (f55eeb7 adds only the docs line above).pnpm --filter @objectstack/mcp typecheck: exit 0.dispatch-gates.mjs --commands, re-derived at f55eeb7, 98 commands): 93 exit 0. Not measured locally, CI runs them:check:dual-build-cjs-loadsandspec check:skill-examples(prerequisite: no builtdist/or declarations for the packages they read),check-plugin-teardown-shape --self-test(shallow clone cannot reach its pinned fixture commit),check:query-options-erasureandcheck:type-check-debt(over the 300 s local cap).Reproduction on main and ablations
main(base 581ae76), a probe sending the failing arguments tovalidate_expressionover HTTP read:MCP error -32602: Input validation error: Invalid arguments for tool validate_expression: Invalid input: expected string, received number at objectNamethenUnrecognized key(s) on this validate_expression call:followed by all ten keys, each with its raw newline and NUL. Nocode, nostatus.scripts/ablation-replace.mjs, delete theanswerToolArgumentRefusalsWithCode(server);call): 4 of 10 tests inrequest-params.test.tsred (both door tests, the misspelling test, the HTTP control); restored, blob == HEAD.withBoundedKeyEchowrap): the two door tests red on the key count (junk_0..junk_8all named, expected five); restored, blob == HEAD. The backstop alone escapes and cuts the keys but does not cap their count, which is why the factory wrap exists.src/directly, so neither ablation needed a rebuild.Acceptance notes
Errorwhose message is thecodedErrorResulttext, and the SDK'stools/callhandler puts a thrown message into the tool error verbatim. The door tests pin the resulting shape on both transports.VALIDATION_ERROR. That is the point of the card; no scorer fixture depends on live server output.packages/runtime/src/domains/mcp-authoring.tsis untouched (open PR feat(metadata-core)!: a knowledge source is saved only on a deployment that mounts the knowledge service #38013 owns it).content/docs/deployment/cli.mdx,content/docs/protocol/objectql/types.mdxand the v17.0 release page via the literalunrecognized_keys(the zod issue code this diff reads). Re-read by hand: all three describe spec metadata refusals (os validate,FieldSchema), not an MCP tool argument; none is changed by this diff. The page this diff did falsify,knowledge-rag.mdx, the check did not list; it was found by grepping the docs for-32602.Verification
packages/mcp/src/request-params.ts(answerToolArgumentRefusalsWithCode,toolArgumentRefusalText,issueSentence),packages/mcp/src/argument-echo.ts, thewithBoundedKeyEchohunk inpackages/mcp/src/mcp-http-tools.ts.pnpm --filter @objectstack/mcp exec vitest run --maxWorkers=2 src/request-params.test.ts— expect 10/10, including the threeanswers the coded refusaltests.Generated by Claude Code