Skip to content

feat(ai): record expected MCP failure messages on the dispatcher span - #1961

Merged
Makisuo merged 18 commits into
perf/run-sql-trace-seek-row-capfrom
feat/mcp-failure-message-span
Oct 30, 2026
Merged

Makisuo merged 18 commits into
perf/run-sql-trace-seek-row-capfrom
feat/mcp-failure-message-span

Merge branch 'perf/run-sql-trace-seek-row-cap' into feat/mcp-failure-…

7d6b523
Select commit
Loading
Failed to load commit list.
Maple Review Bot / Maple / review succeeded Oct 30, 2026 in 1m 12s

Confidence 10/10 · No issues found

🟢 Confidence 10/10 · safe to merge
A four-line span annotation with both presence and the 500-character cap pinned by tests in dispatcher.test.ts; no behavior outside telemetry changes.
no findings · tests covered · risk low

Adds maple.mcp.error.message — a 500-character prefix of the failure text — to the dispatcher span so an expected MCP 4xx can be diagnosed from traces without joining logs. Contained and tested; safe to merge.

  • recordExpectedMcpFailure annotates maple.mcp.error.message, capped at MAX_SPAN_MESSAGE_CHARS
  • dispatcher.test.ts pins the cap and that a short message arrives whole
What was checked
  • Every mapped tag reaches the annotator through recordExpectedMcpFailure (apps/ai/src/mcp/dispatcher.ts:94-148), so budget and invalid-input failures both get the attribute
  • The cap test fails if the attribute is absent, since String(undefined) is not a prefix of the message
  • Message builders traced for secrets: the malformed-bearer text echoes only placeholder names matched by PLACEHOLDER (apps/ai/src/mcp/lib/resolve-tenant.ts:92-104)

7d6b523 · Updated on every push. Reply "won't fix" to dismiss a finding, or mention @maple-review-bot to ask about one.