Skip to content

fix(cron): trim trailing whitespace from recognized job object keys - #95674

Merged
openclaw-clownfish[bot] merged 2 commits into
openclaw:mainfrom
zw-xysk:fix/cron-tool-key-trailing-space-95407-v2
Jun 22, 2026
Merged

openclaw-clownfish[bot] merged 2 commits into
openclaw:mainfrom
zw-xysk:fix/cron-tool-key-trailing-space-95407-v2

Conversation

@zw-xysk

@zw-xysk zw-xysk commented Jun 22, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #95407

What Problem This Solves

Some tool-call extraction/serialization pipelines produce cron object keys with trailing spaces (e.g. "schedule " instead of "schedule"), causing gateway validation to reject the job with "unexpected property" errors.

Only specific top-level keys are affected (schedule, sessionTarget, payload, enabled). Nested keys and keys like name/description are not affected.

Evidence

Fix

Added repairPaddedCronKeys() to canonicalizeCronToolObject() that trims whitespace from recognized cron object keys before any schema processing.

Safety design:

  • Only recognized CRON_RECOVERABLE_OBJECT_KEYS are trimmed — arbitrary keys (including __proto__, constructor) are never mutated
  • Duplicate preservation: when both padded and canonical form exist (e.g. "schedule" and "schedule "), the padded key is preserved so strict gateway validation rejects the ambiguous input rather than silently picking one value
  • Non-duplicate trimming: when only the padded form exists, it is trimmed to its canonical form

Real behavior proof

  • Behavior addressed: cron tool add/update actions fail with "unexpected property 'schedule '" when model generates keys with trailing whitespace
  • Real environment tested: local source checkout, Node.js v24.13.1, Linux x64
  • Exact steps or command run after this patch:
    $ node --import tsx scripts/cron-trim-proof.ts
    
  • Evidence after fix:
    === Real behavior proof: cron key trimming (#95407) ===
    
    Test 1: Only padded 'schedule ' key -> trimmed to 'schedule'
      Input:  {"schedule ":...,"enabled ":true}
      Output: {"schedule":...,"enabled":true}
      schedule: present OK
      'schedule ' removed: yes OK
    
    Test 2: Both 'schedule' and 'schedule ' -> padded preserved (gateway rejects)
      Input:  {"schedule":{every},"schedule ":{cron}}
      Output: {"schedule":{every},"schedule ":{cron}}
      schedule.kind: every (canonical untouched OK)
      'schedule ' preserved: true (gateway will reject OK)
    
    Test 3: Non-recognized '__proto__ ' key -> NOT trimmed
      Input:  {"name":"safe"," __proto__ ":{"malicious":true}}
      Output: {"name":"safe"," __proto__ ":{"malicious":true}}
      ' __proto__ ' preserved: true (safe OK)
    
    Test 4: Normal keys without whitespace -> unchanged
      All keys preserved: yes OK
    
    === All checks passed ===
    
  • Observed result after fix: padded-only keys are correctly trimmed to canonical form; duplicate padded+canonical keys are preserved for gateway rejection; non-recognized keys (including __proto__) are never mutated; normal keys are unchanged
  • What was not tested: live E2E with Qwen 3.5B via llama.cpp (requires specific hardware/model setup)

Tests (5 new, 133 total)

Test Scenario Result
trailing-space job keys add with schedule / sessionTarget / payload / enabled OK
trailing-space patch keys update with padded keys in patch OK
non-recognized keys untouched proto, constructor with spaces NOT trimmed OK
duplicate canonical+ padded both schedule and schedule present padded preserved OK
clean keys preserved normal keys without whitespace unchanged OK
Test Files  2 passed (2)
Tests  133 passed (133)

Checks

  • Format: oxfmt ✓
  • Lint: oxlint ✓
  • Diff: +24 source, +131 test (155 total)
  • Branch: clean from origin/main

…penclaw#95407)

Some tool-call extraction/serialization pipelines can produce cron object
keys with trailing spaces (e.g. 'schedule ' instead of 'schedule'), causing
gateway validation to reject the job.

Add repairPaddedCronKeys() to canonicalizeCronToolObject() that trims only
recognized CRON_RECOVERABLE_OBJECT_KEYS. Non-recognized keys (including
special ones like '__proto__') are never trimmed, preventing prototype
pollution. When both padded and canonical forms exist, the canonical key
wins.

Tests:
- add job with trailing-space keys -> trimmed
- update patch with trailing-space keys -> trimmed
- non-recognized padded keys left intact (safety)
- canonical key preserved over padded duplicate
- clean keys unchanged

133 tests pass (128 existing + 5 new).
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. and removed triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Jun 22, 2026
@clawsweeper

clawsweeper Bot commented Jun 22, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed June 22, 2026, 2:28 PM ET / 18:28 UTC.

Summary
The PR adds allowlisted whitespace trimming for recognized cron job/patch object keys in cron tool canonicalization plus regression tests for padded, duplicate, unsafe, and clean-key cases.

PR surface: Source +28, Tests +136. Total +164 across 2 files.

Reproducibility: yes. source-level: current main passes whitespace-padded cron job/patch keys through the cron canonicalizer, and the strict gateway cron schemas reject unexpected properties. I did not run the live qwen35b/llama.cpp route in this read-only review.

Review metrics: none identified.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #95407
Summary: This PR is one of several open candidate fixes for the canonical whitespace-padded cron job key bug.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🐚 platinum hermit
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • none.

Risk before merge

  • [P1] Several open PRs target the same canonical cron key-mangling issue, so maintainers should choose one landing path and close the siblings after merge.
  • [P1] The proof is terminal/source-level against the cron canonicalizer rather than a live qwen35b/llama.cpp end-to-end run, which is a reasonable gap to note before landing.

Maintainer options:

  1. Decide the mitigation before merge
    Land one narrow allowlisted cron canonicalization fix, then close the duplicate candidate PRs once the canonical fix merges.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P2] Maintainers need to choose the canonical fix among several open sibling PRs; there is no narrow ClawSweeper repair needed on this branch.

Security
Cleared: The diff touches only cron argument canonicalization and tests, with no dependency, workflow, secret, install, package, or supply-chain changes.

Review details

Best possible solution:

Land one narrow allowlisted cron canonicalization fix, then close the duplicate candidate PRs once the canonical fix merges.

Do we have a high-confidence way to reproduce the issue?

Yes, source-level: current main passes whitespace-padded cron job/patch keys through the cron canonicalizer, and the strict gateway cron schemas reject unexpected properties. I did not run the live qwen35b/llama.cpp route in this read-only review.

Is this the best way to solve the issue?

Yes, the cron canonicalizer is the best boundary for this reported nested job/patch repair because earlier model-friendly cron argument recovery already lives there and gateway validation remains strict. The remaining maintainer decision is which sibling PR should be the canonical landing path.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 03ba09bfa867.

Label changes

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body now includes after-fix terminal output from a local source checkout exercising the changed cron canonicalizer behavior; it is source-level rather than live provider E2E proof.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body now includes after-fix terminal output from a local source checkout exercising the changed cron canonicalizer behavior; it is source-level rather than live provider E2E proof.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 🛠️ actively grinding: Current PR status label is status: 👀 ready for maintainer look.
  • remove merge-risk: 🚨 other: Current PR review selected no merge-risk labels.

Label justifications:

  • P2: This is a bounded cron tool argument-recovery bug affecting scheduled job creation for affected local-model users.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body now includes after-fix terminal output from a local source checkout exercising the changed cron canonicalizer behavior; it is source-level rather than live provider E2E proof.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body now includes after-fix terminal output from a local source checkout exercising the changed cron canonicalizer behavior; it is source-level rather than live provider E2E proof.
Evidence reviewed

PR surface:

Source +28, Tests +136. Total +164 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 28 0 +28
Tests 1 136 0 +136
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 164 0 +164

What I checked:

  • Repository policy read: Read the full root AGENTS.md and scoped src/agents plus src/agents/tools AGENTS.md files; the review applied the read-beyond-diff and agent-tool performance guidance, and no matching maintainer note applied because the only note present was Telegram-specific. (AGENTS.md:1, 03ba09bfa867)
  • Current main behavior: Current main unwraps job/data, copies the object, then runs concatenated-key, schedule, and payload canonicalization without repairing whitespace-padded keys such as schedule before gateway dispatch. (src/agents/tools/cron-tool-canonicalize.ts:247, 03ba09bfa867)
  • Cron tool entry points: The add and update branches both route job/patch objects through canonicalizeCronToolObject before cron.add or cron.update, so the touched helper sits on the affected dispatch path. (src/agents/tools/cron-tool.ts:937, 03ba09bfa867)
  • Strict gateway validation: CronAddParamsSchema and CronJobPatchSchema use exact property names with additionalProperties: false, matching the reported unexpected-property failure when padded keys reach the gateway. (packages/gateway-protocol/src/schema/cron.ts:478, 03ba09bfa867)
  • Patch behavior: The PR adds repairPaddedCronKeys before existing cron canonicalization, trims only names whose trimmed form is in CRON_RECOVERABLE_OBJECT_KEYS, and preserves padded duplicates when the canonical key already exists so strict validation can reject ambiguity. (src/agents/tools/cron-tool-canonicalize.ts:246, 697b81489cc3)
  • Regression coverage: The PR adds tests for padded job keys, padded update patch keys, unrecognized padded keys, duplicate canonical+padded keys, and clean keys in the cron tool flat-params test file. (src/agents/tools/cron-tool.flat-params.test.ts:181, 697b81489cc3)

Likely related people:

  • steipete: GitHub path history shows repeated adjacent cron canonicalization and flat-parameter recovery work, including the split of cron tool repair helpers and related live model inference fixes. (role: recent related fix author; confidence: high; commits: cd3b467f3c21, 972d2b66d183, 9ead0ae9219e; files: src/agents/tools/cron-tool-canonicalize.ts, src/agents/tools/cron-tool.ts, src/agents/tools/cron-tool.flat-params.test.ts)
  • vincentkoc: Local blame in this checkout and GitHub path history point to recent cron tool and cron schema maintenance around the same agent-tool surface. (role: recent area contributor and reviewer; confidence: medium; commits: aa396007937b, ca1a53aca4ba, 9dd7f04b71e8; files: src/agents/tools/cron-tool-canonicalize.ts, src/agents/tools/cron-tool.ts)
  • 849261680: GitHub path history shows a recent cron canonicalizer change for payload model override handling in the same small module. (role: recent canonicalizer contributor; confidence: medium; commits: cfeaf6897fd8; files: src/agents/tools/cron-tool-canonicalize.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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 keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. labels Jun 22, 2026
… exists (openclaw#95407)

When both a padded key (e.g. 'schedule ') and its canonical form
('schedule') exist, the padded key is now preserved so strict gateway
validation rejects the ambiguous input rather than silently picking one
value. Only padded keys without a canonical counterpart are trimmed.
@zw-xysk

zw-xysk commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

Addressed both ClawSweeper findings:

  1. [P1] Duplicate preservation: when both padded and canonical keys exist, the padded key is now preserved so gateway validation rejects the conflict (was: silently picking canonical)
  2. [P1] Real behavior proof: added real terminal output from node --import tsx invoking canonicalizeCronToolObject directly (Test 1-4 above)

@clawsweeper re-review

@clawsweeper clawsweeper Bot added status: 🛠️ actively grinding The PR author has acted after the latest ClawSweeper review and work remains. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 🛠️ actively grinding The PR author has acted after the latest ClawSweeper review and work remains. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. labels Jun 22, 2026
@openclaw-clownfish
openclaw-clownfish Bot merged commit 3a32d24 into openclaw:main Jun 22, 2026
55 of 66 checks passed
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jun 23, 2026
…penclaw#95674)

* fix(cron): trim trailing whitespace from recognized job object keys (openclaw#95407)

Some tool-call extraction/serialization pipelines can produce cron object
keys with trailing spaces (e.g. 'schedule ' instead of 'schedule'), causing
gateway validation to reject the job.

Add repairPaddedCronKeys() to canonicalizeCronToolObject() that trims only
recognized CRON_RECOVERABLE_OBJECT_KEYS. Non-recognized keys (including
special ones like '__proto__') are never trimmed, preventing prototype
pollution. When both padded and canonical forms exist, the canonical key
wins.

Tests:
- add job with trailing-space keys -> trimmed
- update patch with trailing-space keys -> trimmed
- non-recognized padded keys left intact (safety)
- canonical key preserved over padded duplicate
- clean keys unchanged

133 tests pass (128 existing + 5 new).

* fix(cron): preserve padded duplicate keys when canonical form already exists (openclaw#95407)

When both a padded key (e.g. 'schedule ') and its canonical form
('schedule') exist, the padded key is now preserved so strict gateway
validation rejects the ambiguous input rather than silently picking one
value. Only padded keys without a canonical counterpart are trimmed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: cron tool add action mangles certain key names in job parameter

1 participant