Repository navigation
fix(claws): refuse malformed UTF-8 before adding agents - #180741
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 real behavior proof before merge. What this changesReject malformed UTF-8 in Claw JSON manifests, package metadata, and OpenClaw YAML profiles before agent creation. Example: A JSON manifest encodes the agent name Café using a lone Latin-1 byte E9.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 1 item remains Keep this PR open: it fixes a concrete import-corruption path still present on current main, and no actionable patch defects were found. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherClaw readers turn bounded package files into validated manifests, profiles, and raw-byte snapshots consumed by inspection, package validation, registry intake, and Add. flowchart LR
Files[Claw source files] --> Readers[Bounded file readers]
Readers --> Decoder[Strict UTF-8 decoding]
Decoder --> Parser[JSON and YAML parsing]
Parser --> Validation[Schema validation]
Validation --> Consumers[Inspect and Add]
Decoder --> Errors[Encoding diagnostics]
Technical reviewBest possible solution: Use the existing strict decoder at both intake owners while preserving raw-byte integrity, supported Unicode, and format-specific BOM behavior. Do we have a high-confidence way to reproduce the issue? Current-main readers visibly replacement-decode malformed bytes before parsing, and the added filesystem regressions exercise concrete accepted corruption cases; no target code was run during this review. Is this the best way to solve the issue? This is the smallest complete fix: reject malformed bytes before parsing through the existing owners, without new state, wrappers, or caller-specific policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against c8dfebcfaee8. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +2, Tests +54, Docs +3. Total +59 across 5 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
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 HistoryReview history (1 earlier review cycle)
Reviewed October 24, 2026, 7:43 PM ET / 23:43 UTC (Revision 2). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
What Problem This Solves
Fixes Claw inspection and Add accepting malformed JSON or YAML bytes as altered names, manifest paths, or policy text.
User Impact
Malformed UTF-8 is rejected with the existing source diagnostic before Add plans or creates an agent. Valid Unicode, JSON BOM rejection, YAML BOM support, legacy profile pointers, and byte-based integrity checks retain their behavior.
Why This Change Was Made
Both text intake owners use the existing
decodeUtf8Inputbefore parsing, while retaining the original bytes for integrity hashing. The profile reader also reuses its existing filesystem root instead of creating it twice.Thanks to @Leon-SK668 for the original fix and Linux CLI reproduction.
Evidence
node scripts/run-vitest.mjs src/claws/reader.test.ts src/claws/openclaw-profile.test.ts --maxWorkers=1: all 40 tests pass, including BOM, bounds, integrity, link admission, and legacy-profile controls. After merging current main, all 40 tests passed again (277.22 s wrapper / 225.79 s Vitest). The earlier green run took 251.83 s / 201.81 s; the base red run took 241.81 s / 209.15 s. Most time was module compilation (98% of the green Vitest duration), not test execution.The contributor's original PR includes compiled Linux CLI proof pinned to
c52cfbb5ce46d8dc4142d3152b663aff148018bc. This revision exercises the real filesystem and inspection owner; the built CLI and live Gateway were not rerun because a separate full build was not proportionate. The Add caller returns on a failed source read before planning or creating resources.Independent P0–P2 autoreview completed with no actionable findings.
The previous head passed all 68 CI jobs (run 40139956445), but the separate security-review workflow failed on inconsistent GitHub diff metadata (13,906 reported files versus the five-file local diff). A normal merge of current main preserves the reviewed five-file patch byte-for-byte and refreshes that required check.
Prior-head compiled CLI trace (contributor evidence)
The following captured Linux output predates this revision. The contributor ran
node ../claw-source-utf8-proof-20261022.mjsagainst basece54bc879ad922006023cf889f1f38df9efd689dand candidatec52cfbb5ce46d8dc4142d3152b663aff148018bcon October 22, using Node 24.22.1 and isolated synthetic state. It is retained for inspection, not claimed as runtime proof of the current head.Captured native output and independent readback
The malformed manifest contains byte sequence
c3 28inside the agent name. These are captured output excerpts; only temporary roots are redacted as<proof-root>and unrelated fields are omitted.Base
claws add ... --jsonexits 0 and reports:{ "status": "complete", "agent": { "requestedId": "utf8-import", "finalId": "utf8-import", "workspace": "<proof-root>/manifest/rejected-workspace", "config": { "id": "utf8-import", "name": "Caf�(", "workspace": "<proof-root>/manifest/rejected-workspace" } }, "workspaceCreated": true, "configCommitted": true }A subsequent
agents list --jsonprocess reads the stored agent back with"id": "utf8-import", "name": "Caf�(". For the profile variant, a subsequentconfig get agents.entries.utf8-import.groupChat.mentionPatterns --jsonexits 0 and reads:[ "@caf�(" ]At the candidate head, the identical malformed manifest Add exits 1 with this complete stdout:
{ "schemaVersion": "openclaw.clawAddPlan.v1", "stability": "experimental", "valid": false, "diagnostics": [ { "level": "error", "code": "invalid_json", "phase": "parse", "path": "$", "message": "Could not parse <proof-root>/manifest/source/openclaw.claw.json: <proof-root>/manifest/source/openclaw.claw.json must be valid UTF-8." } ] }Fresh agent-list readback contains only
main; the rejected workspace is absent and config/source bytes match their pre-Add hashes. The profile variant reportsopenclaw_profile_read_failedat$.profiles.openclawwithprofiles/openclaw.yml must be valid UTF-8.The package variant refuses before a replacement-decoded manifest path can select a different file.Re-encoding the sources and retrying Add exits 0, creates exactly one agent per isolated case, and fresh
agents list --jsonreads"name": "Café �( 😺". The repaired BOM-prefixed profile's fresh config readback is:[ "@café �( 😺" ]This distinguishes legitimate U+FFFD from invalid input bytes rather than rejecting a character in the decoded string.