feat(cron): support custom job ids on add#2444
Open
BingqingLyu wants to merge 1 commit into
Open
Conversation
This was referenced May 28, 2026
Owner
Author
|
| Function | File | Also modified by |
|---|---|---|
createJob |
src/cron/service/jobs.ts |
#2076 |
cronIdOrJobIdParams |
src/gateway/protocol/schema/cron.ts |
#2076, #2127, #2419, #2525 |
normalizeCronJobInput |
src/cron/normalize.ts |
#2076, #2127 |
normalizeMainSystemEventCreateJob |
src/cron/normalize.test.ts |
#2127, #2245, #2502 |
Recommendation: Coordinate with #2076, #2127, #2245, #2419, #2502, #2525 before merging.
Auto-detected by codegraph — a code graph analysis tool built on neug.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Describe the problem and fix in 2–5 bullets:
openclaw cron addalways generated a UUID and had no supported way to create a stable human-readable job id.cron edit,cron run,cron runs --id, or automation/scripts that refer back to an existing job.--idtocron add, validated safe custom ids at the protocol/service layer, preserved them on create, and reject collisions with an explicit error.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause (if applicable)
For bug fixes or regressions, explain why this happened, not just what changed. Otherwise write
N/A. If the cause is unclear, writeUnknown.idend-to-end.CronJobCreateexcluded it, the CLI exposed no flag, the add schema rejected it, and the service always calledrandomUUID().Regression Test Plan (if applicable)
For bug fixes or regressions, name the smallest reliable test coverage that should catch this. Otherwise write
N/A.src/cli/cron-cli.test.tssrc/gateway/protocol/cron-validators.test.tssrc/cron/normalize.test.tssrc/cron/service.get-job.test.tscron add --id daily-briefforwards the id, safe ids validate, whitespace-only ids are dropped during normalization, created jobs keep the requested id, and duplicate ids fail clearly.User-visible / Behavior Changes
openclaw cron addnow accepts--id <id>.cron job id already exists: <id>.Diagram (if applicable)
Security Impact (required)
Yes/No) YesYes/No) NoYes/No) NoYes/No) NoYes/No) NoYes, explain risk + mitigation: this adds a new user-controlled identifier surface for cron jobs, so the implementation restricts ids to a file-safe slug-like character set and rejects duplicates before persistence.Repro + Verification
Environment
v25.7.0, pnpm10.32.1Steps
Expected
Actual
Evidence
Attach at least one:
Human Verification (required)
What you personally verified (not just CI), and how:
npx --yes pnpm exec vitest run src/cli/cron-cli.test.ts src/gateway/protocol/cron-validators.test.ts src/cron/normalize.test.ts src/cron/service.get-job.test.tsand confirmed all targeted tests pass.pnpm build && pnpm check && pnpm testacross the entire monorepo.Review Conversations
If a bot review conversation is addressed by this PR, resolve that conversation yourself. Do not leave bot review conversation cleanup for maintainers.
Compatibility / Migration
Yes/No) YesYes/No) NoYes/No) NoRisks and Mitigations
List only real risks for this PR. Add/remove entries as needed. If none, write
None.--idis explicit/optional, and omitting it keeps the old UUID behavior unchanged.