Repository navigation
fix(cron): trim trailing whitespace from cron tool job keys in canonicalization (fixes #95407) - #95421
fix(cron): trim trailing whitespace from cron tool job keys in canonicalization (fixes #95407)#95421zenglingbiao wants to merge 4 commits into
Conversation
|
Codex review: needs changes before merge. Reviewed June 22, 2026, 12:29 AM ET / 04:29 UTC. Summary PR surface: Source +28, Tests +160. Total +188 across 3 files. Reproducibility: yes. Source inspection shows current main leaves whitespace-padded cron job keys unchanged before strict cron.add validation requires exact property names; I did not replay a live qwen35b/llamacpp serializer session. Review metrics: 1 noteworthy metric.
Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Add braces to the new guard clauses, keep the narrow cron-canonicalizer repair, rerun lint and focused cron tests, then land one canonical PR for the linked bug. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection shows current main leaves whitespace-padded cron job keys unchanged before strict cron.add validation requires exact property names; I did not replay a live qwen35b/llamacpp serializer session. Is this the best way to solve the issue? Mostly yes. The cron canonicalizer is the right narrow boundary for this reported job-key corruption, but this branch must first satisfy lint and then be selected over the sibling candidate PRs. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against a594d2ce7325. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +28, Tests +160. Total +188 across 3 files. View PR surface stats
Acceptance criteria:
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
…uard (fixes openclaw#95407) - Replace normalizeCronToolKeys (null-prototype object, regex filter) with repairWhitespacePaddedCronToolKeys (in-place, recognized keys only) - In-place modification follows the existing repairConcatenatedCronToolKeys pattern - Only CRON_RECOVERABLE_OBJECT_KEYS are trimmed; unknown keys pass through for strict schema validation to reject - Preserve genuine duplicates when the canonical key already exists - No prototype pollution risk: operates on a plain spread copy - Add execute-path regression tests in cron-tool.test.ts - Update flat-params tests with leading-space, duplicate-key, and clean-key coverage
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Closing: issue #95407 already resolved by other merged PRs. See comment above. |
Summary
crontool withaction: "add", certain top-level keys in thejobJSON (schedule,sessionTarget,payload,enabled) can arrive with trailing spaces appended by the streaming JSON parser ("schedule ", etc.). This causes schema validation to reject the call with missing-required-property errors.canonicalizeCronToolObjectinsrc/agents/tools/cron-tool-canonicalize.tscopies the input object as-is. Keys with trailing whitespace are not matched byCRON_RECOVERABLE_OBJECT_KEYS(which expects exact names like"schedule"), so canonicalization silently drops them and the downstream schema validator sees missing required fields.normalizeCronToolKeyshelper that trims leading/trailing whitespace from every top-level key before canonicalization runs. The trim step is applied incanonicalizeCronToolObjectimmediately after unwrapping the input.src/agents/tools/cron-tool-canonicalize.ts— addednormalizeCronToolKeys(~12 lines); call it beforerepairConcatenatedCronToolKeyssrc/llm/utils/json-parse.tswas not modified — the fix is scoped to the cron tool canonicalization layer onlyReproduction
crontool withaction: "add"and ajobparameter whose keys have trailing spaces (as produced by streaming/partial-json parsers)schedule,sessionTarget,payload,enabledkeys are not recognized → schema validation failscanonicalizeCronToolObjectdrops them → "missing required property" errorsReal behavior proof
Behavior or issue addressed (#95407): Cron tool
addaction rejects valid job input when streaming JSON parser appends trailing spaces to property namesReal environment tested: Linux, Node v22.22.0, OpenClaw 2026.6.x (29ec5b3) built from source. A standalone
node --import tsxscript drovecanonicalizeCronToolObjectagainst a job input with four trailing-space keys matching the exact reproduction case from the issue.Exact steps or command run after this patch: ran
node --import tsx proof.mjsimporting the fixedcron-tool-canonicalize.tsdirectlyEvidence before fix:
Evidence after fix:
Observed result after fix: All four trailing-space keys are normalized to their expected names before canonicalization runs. The schedule/payload canonicalization then processes them correctly, and the downstream schema validator sees the expected property names.
What was not tested: A live gateway with an actual LLM producing the trailing-space JSON was not driven. The proof exercises the exact canonicalization code path that receives the LLM-parsed JSON.
Repro confirmation: Colocated cron tool regression suites run successfully after the fix —
cron-tool.test.ts,cron-tool.schema.test.ts, andcron-tool.flat-params.test.ts(146 tests total, all passing).Risk / Mitigation
Mitigation: The LLM produces trailing spaces, not leading spaces; distinct keys that differ only by whitespace are not a realistic tool-call scenario. If both a trimmed and untrimmed key exist, later assignments naturally win.
Mitigation: The cron tool is the most structured job object with many required top-level keys, making it the most vulnerable. Other tools can adopt the same pattern if needed; a global JSON parse fix carries higher merge-risk.
Change Type (select all)
Scope (select all touched areas)
Regression Test Plan
node scripts/run-vitest.mjs src/agents/tools/cron-tool.test.ts src/agents/tools/cron-tool.schema.test.ts src/agents/tools/cron-tool.flat-params.test.ts(146 tests)Review Findings Addressed
__proto__key → fixed in bb1b0a6: useObject.create(null)accumulator and explicitly reject__proto__key; restrict accepted keys to recognized cron fields or standard identifier patterns__proto__rejection, value preservation)Linked Issue/PR
Fixes #95407