Repository navigation
Conversation
|
Codex review: needs maintainer review before merge. Summary Reproducibility: yes. Current main gives a high-confidence source-level reproduction: add pushes a second normalized name without a sibling check, and update can patch a job name before replacement without checking sibling names; the linked issue also provides CLI steps. Next step before merge Security Review detailsBest possible solution: Land the service-level duplicate-name guard after exact-head CI passes, and track --replace or legacy duplicate-list warnings separately if maintainers want that UX. Do we have a high-confidence way to reproduce the issue? Yes. Current main gives a high-confidence source-level reproduction: add pushes a second normalized name without a sibling check, and update can patch a job name before replacement without checking sibling names; the linked issue also provides CLI steps. Is this the best way to solve the issue? Yes for the default rejection fix. A service-level RangeError guard after name normalization covers CLI, agent-tool, Gateway, and future callers while preserving the existing INVALID_REQUEST mapping. What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 10448a0ad14c. |
…openclaw#76160) Two cron.add calls with identical names pushed both rows into jobs.json with no validation. If both were enabled they fired twice per cycle with divergent prompts; if one was disabled the duplicate was invisible in the default cron list view (disabled rows filtered). cron.update could also silently rename onto an existing name through the same gap. Add findJobByName helper in jobs.ts and guard both paths in ops.ts: - add: throw before push if any existing job has the same normalized name - update: throw after applyJobPatch if the patched name collides with a different job (same-job rename onto itself is allowed) Error messages include the colliding job's id so operators can decide whether to remove the old job or choose a different name. Tests (4 new in ops.test.ts): refuse on collision, refuse when existing job is disabled, refuse rename onto existing name, allow rename onto same name. 11/11. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…claw#76160) Address clawsweeper P2: plain Error from duplicate-name guards was rethrown as UNAVAILABLE. Change to RangeError so the gateway cron.add/cron.update handlers map it to INVALID_REQUEST. Add gateway regression tests for the duplicate-name INVALID_REQUEST path in cron.validation.test.ts. Tests: 41/41 (ops.test.ts + cron.validation.test.ts). oxlint: 0/0. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Problem
`cron add` and `cron edit` silently accepted new jobs whose `name` collided with an existing job's `name`. Two distinct rows with identical names landed in `jobs.json`, each with its own `id`, `schedule`, and `enabled` state. If both rows were enabled they fired twice per cycle with divergent prompts; if one was disabled, the duplicate was invisible in the default `cron list` output (disabled rows filtered unless `--all`). `cron edit --name ` could also silently rename onto an existing job through the same gap in `ops.update`.
Fixes #76160.
Root cause
`ops.add` called `state.store.jobs.push(job)` with no name uniqueness check.
`ops.update` applied the name patch and replaced the job by ID without checking sibling names.
Changes
`src/cron/service/jobs.ts`
`src/cron/service/ops.ts`
Test result
`11 passed (11)` in `src/cron/service/ops.test.ts`. 4 new cases:
`oxlint`: 0 warnings, 0 errors on all changed files.