Repository navigation
fix(gateway): keep an astral MCP event description whole at the catalog cap - #181741
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR preserves complete UTF-16 surrogate pairs when truncating MCP event descriptions to the existing 4096-unit limit. Example: calendar.changed has a description containing 4095 ASCII a characters followed by 😀 and tail.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a current-main Unicode truncation bug with a minimal change and meaningful regression coverage; no actionable defects were found. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe Gateway retrieves event definitions from configured MCP servers and projects a bounded catalog for the Automation editor and MCP Events discovery tool. flowchart LR
A[Catalog client] --> B[Gateway RPC]
B --> C[Configured MCP server]
C --> D[Catalog projection]
D --> E[UTF16 truncation helper]
E --> F[Bounded catalog response]
Technical reviewBest possible solution: Retain the canonical-helper substitution and focused catalog-response regression. Do we have a high-confidence way to reproduce the issue? Current-main source deterministically splits the reported surrogate pair, matching the supplied Gateway red/green results; this read-only review did not execute target code. Is this the best way to solve the issue? This is the smallest complete fix: reuse the existing surrogate-safe truncation owner while preserving the catalog limit and response shape. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 2e267509979f. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +1, Tests +15. Total +16 across 2 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReviewed October 24, 2026, 11:13 AM ET / 15:13 UTC (Revision 3). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
# Conflicts: # src/gateway/server-methods/mcp-events.ts
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Landed in 3fe9908. Thanks @wangmiao0668000666. mcp.events.list descriptions no longer split emoji. |
|
Thanks @obviyus for reviewing and merging this — keeping the astral MCP event description whole at the catalog cap helps avoid truncating useful context for the gateway path. Appreciate the quick turnaround! |
…og cap (openclaw#181741) fix(mcp): don't split an emoji in mcp.events.list descriptions mcp.events.list cut event descriptions at 4096 UTF-16 units, which could split an emoji and return a lone surrogate (invalid Unicode) to clients. The cut now uses the existing truncateUtf16Safe owner and stops at a whole character; paging is unchanged. Evidence: built Gateway, mcp.events.list over the public RPC. On main a description ending in an emoji came back as 4096 units with a lone U+D83D (twice); with this change it is 4095 units of valid text (twice). Short descriptions and the next-page cursor are unchanged. Thanks @wangmiao0668000666. Co-authored-by: Ayaan Zaidi <[email protected]>
…og cap (#181741) fix(mcp): don't split an emoji in mcp.events.list descriptions mcp.events.list cut event descriptions at 4096 UTF-16 units, which could split an emoji and return a lone surrogate (invalid Unicode) to clients. The cut now uses the existing truncateUtf16Safe owner and stops at a whole character; paging is unchanged. Evidence: built Gateway, mcp.events.list over the public RPC. On main a description ending in an emoji came back as 4096 units with a lone U+D83D (twice); with this change it is 4095 units of valid text (twice). Short descriptions and the next-page cursor are unchanged. Thanks @wangmiao0668000666. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 3fe9908) Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit f9828683b0d4827c61333c594a847564e64150a9)
…og cap (#181741) [baseline validation follow-up] fix(mcp): don't split an emoji in mcp.events.list descriptions mcp.events.list cut event descriptions at 4096 UTF-16 units, which could split an emoji and return a lone surrogate (invalid Unicode) to clients. The cut now uses the existing truncateUtf16Safe owner and stops at a whole character; paging is unchanged. Evidence: built Gateway, mcp.events.list over the public RPC. On main a description ending in an emoji came back as 4096 units with a lone U+D83D (twice); with this change it is 4095 units of valid text (twice). Short descriptions and the next-page cursor are unchanged. Thanks @wangmiao0668000666. Co-authored-by: Ayaan Zaidi <[email protected]> Complete the source-equivalent baseline adaptation and checked-in regressions; normalize with the checkout formatter. (cherry picked from commit 3fe9908) Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 8701eac4c6483cee63d95d9206d483643f975afd)
What Problem This Solves
mcp.events.listcould split an astral character at the existing 4,096 UTF-16-unit description cap and return a lone surrogate. ReusetruncateUtf16Safe, following #176207 and #176230, without changing the cap or MCP catalog contract.Evidence
Built main and candidate in isolated Node 24.22.1 Docker. Configured the bundled MCP Events plugin normally against an external loopback Streamable HTTP fixture implementing
server/discoverandevents/list. Called the running Gateway through shippedgateway call mcp.events.list --json.aaaaaa\ud83d.aaaaaaa.short 😀 description, 20 units, well formed;nextCursor: page2preserved.Simplification keeps the existing truncation owner: production +2/-1 lines; tests +15/-0 against main. The focused regression protects the split-surrogate boundary.
Thanks to @wangmiao0668000666 for reporting and fixing this.
Two-way door: a revert restores the previous read-only projection. No persisted state or config changes. Blast radius is descriptions in MCP event discovery RPC responses.