fix(cron): reject invalid cron expressions on disabled jobs before persisting#13
Open
suboss87 wants to merge 51 commits into
Open
fix(cron): reject invalid cron expressions on disabled jobs before persisting#13suboss87 wants to merge 51 commits into
suboss87 wants to merge 51 commits into
Conversation
…nt disabled-job loophole
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.
Closes openclaw#74459
Problem
openclaw cron edit <id> --cron "invalid expr"on a disabled job silently persisted the invalid expression. Two bugs:ops.updateonly callscomputeJobNextRunAtMs(which validates viacroner) for enabled jobs. Disabled jobs skip that path entirely, so invalid cron syntax passes through topersist().cron edit --enable,applyJobPatchsetjob.enabled = truebeforecomputeJobNextRunAtMsthrew, leaving the in-memorystate.store.jobsentry withenabled: trueeven thoughpersistwas never reached. This "live state" corruption persisted until the next forced reload from disk.Root cause
src/cron/service/ops.ts:update:Fix
Added
validateCronScheduleExpr(schedule)tosrc/cron/validate-timestamp.ts. It dry-runscomputeNextRunAtMsin a try/catch to detect croner parse errors for any cron-kind schedule.Three call sites:
gateway/server-methods/cron.ts—cron.addandcron.updatehandlers: validate before reachingcontext.cron.*(returns structured error to caller)src/cron/service/ops.ts—update: validate beforeapplyJobPatchso the job object is never mutated when the expression is invalid (defense in depth)Tests
New file
src/cron/service.cron-invalid-expr.test.ts(3 tests):Generated by Claude Code