Skip to content

Fix/cron duplicate name validation - #76445

Closed
habib-agentic-engineer wants to merge 2 commits into
openclaw:mainfrom
habib-agentic-engineer:fix/cron-duplicate-name-validation
Closed

habib-agentic-engineer wants to merge 2 commits into
openclaw:mainfrom
habib-agentic-engineer:fix/cron-duplicate-name-validation

Conversation

@habib-agentic-engineer

Copy link
Copy Markdown

Fixes #76160

`openclaw cron add` and `cron edit` now enforce unique job names, preventing silent duplicate-name acceptance that could lead to dual-fire risk when both jobs remain enabled.

Problem

Previously, the cron service silently accepted jobs with duplicate names:

  • Two `cron add` calls with the same name created two distinct rows with different IDs
  • `cron edit` could rename a job onto an existing name
  • Default `cron list` only showed one job when their `enabled` states differed, hiding the divergence
  • If both jobs remained enabled, they would fire twice per cycle with potentially divergent prompts

Solution

Added name uniqueness validation in the service layer:

  • `cron.add`: Checks for existing job with the same name before creating
  • `cron.update`: Checks for name collision when renaming (allows no-op self-rename)
  • Disabled jobs: Included in uniqueness check to prevent the exact scenario from the bug report
  • Error messages: Clear, actionable format with existing job ID and removal instructions

Implementation

  • `src/cron/service/ops.ts`: Added `findJobByName()` checks in `add()` and `update()`
  • `src/cron/service/jobs.ts`: Added `findJobByName()` helper function
  • `src/cron/service.duplicate-names.test.ts`: Comprehensive test suite (13 test cases)

All entry points (CLI, agent tool, gateway RPC) funnel through the service layer, so validation is enforced everywhere.

Testing

Added dedicated test suite covering:

  • Adding jobs with duplicate names (enabled and disabled)
  • Renaming jobs to existing names (enabled and disabled)
  • Edge cases (case sensitivity, special characters, empty names)
  • No-op renames (renaming to same name)
  • Error message validation

Breaking Changes

None. This is a bug fix that prevents invalid state. Operators who were accidentally creating duplicate names will now receive clear error messages with instructions to resolve the conflict.

Related

@habib-agentic-engineer
habib-agentic-engineer requested a review from a team as a code owner May 3, 2026 04:30
@clawsweeper

clawsweeper Bot commented May 3, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Keep open: current main and v2026.6.11 still allow cron duplicate-name creation, and this PR is a focused candidate, but it is not merge-ready because it misses normalized-name collisions, returns the wrong Gateway error class, lacks real behavior proof, and is currently conflicting.

Root-cause cluster
Relationship: canonical
Canonical: #76445
Summary: This PR is the focused open implementation candidate for cron duplicate-name rejection; related items are either the linked stale-closed report, a closed unmerged prior PR, duplicate-id work, or broader duplicate execution/update issues.

Members:

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

Canonical path: Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review.

So I’m closing this here because the remaining work is already tracked in the canonical issue.

Review details

Best possible solution:

Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review.

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

Yes for source-level reproduction: current main creates and pushes normalized cron jobs without a sibling-name check, and update applies name patches without sibling comparison. I did not run a live CLI/Gateway reproduction in this read-only review.

Is this the best way to solve the issue?

No as submitted. The service boundary is the right layer, but the implementation must compare normalized names and preserve the Gateway invalid-request contract before it is the best fix.

Security review:

Security review cleared: The diff changes cron validation, tests, and changelog text without dependency, workflow, secret, permission, package metadata, or artifact-execution changes.

AGENTS.md: found and applied where relevant.

What I checked:

  • stale F-rated PR: PR was opened 2026-05-03T04:30:40Z, is older than 60 days, and the latest review rated it F.
  • proof blocker: real behavior proof is missing and proof tier is F, so this branch is not merge-ready without contributor follow-up.
  • no human follow-up: live comments and timeline hydrated by apply contain no non-automation activity after the ClawSweeper review.

Likely related people:

  • steipete: Path history shows repeated cron normalization, Gateway cron, and service refactors around the add/update and validation boundary. (role: heavy cron path contributor; confidence: high; commits: 934927fd13, 533bd00001, 39bcf695dc; files: src/cron/service/ops.ts, src/cron/service/jobs.ts, src/gateway/server-methods/cron.ts)
  • tyler6204: Earlier merged cron scheduler, store hardening, delivery, and Gateway cron work shaped the core runtime surface involved here. (role: major cron runtime contributor; confidence: high; commits: d90cac990c, 3a03e38378, 8fae55e8e0; files: src/cron/service/ops.ts, src/cron/service/jobs.ts, src/gateway/server-methods/cron.ts)
  • vincentkoc: Recent release and cron service/runtime split commits touched adjacent cron service boundaries and tests relevant to this fix shape. (role: recent adjacent cron contributor; confidence: medium; commits: e085fa1a3f, 1c9053802a, 42bc411c46; files: src/cron/service/ops.ts, src/cron/service/jobs.ts, src/gateway/server-methods/cron.ts)
  • Takhoffman: History includes cron edit, run-history, stale-run recovery, and persisted job behavior near the add/update paths. (role: adjacent cron feature contributor; confidence: medium; commits: 77c3b142a9, 259d863353, cc5dad81bc; files: src/cron/service/ops.ts, src/cron/service/jobs.ts, src/gateway/server-methods/cron.ts)

Codex review notes: model internal, reasoning high; reviewed against 010b61746379.

@barnacle-openclaw

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@barnacle-openclaw barnacle-openclaw Bot added the stale Marked as stale due to inactivity label May 30, 2026
@clawsweeper clawsweeper Bot added the rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. label May 30, 2026
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. label May 30, 2026
@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: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. and removed rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. labels May 30, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label May 31, 2026
@clawsweeper clawsweeper Bot added rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. and removed 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. labels May 31, 2026
@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. and removed rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. 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. labels Jun 14, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added stale Marked as stale due to inactivity triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Jul 18, 2026
@clawsweeper

clawsweeper Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: Fix/cron duplicate name validation This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Jul 19, 2026
@steipete

Copy link
Copy Markdown
Contributor

Closing per ClawSweeper review verdict abandoned_pr (decision packet 2026-07-18T15:22:27.323Z). This item was part of the audited close backlog (openclaw/clawsweeper#920) stranded by an apply-lane defect, drained manually after re-verification. If this is wrong, reopen and ClawSweeper will re-review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cron: cron add/edit silently allows duplicate name collisions

3 participants