Repository navigation
fix(automations): require decimal cron numbers in new schedule input - #49720
Conversation
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes.
|
1a1092a to
c445ba0
Compare
New cron input parsed values and steps with Number(), so 0x10, 1e1, +5, 5.0 and */0b10 passed validation with a cadence the notation does not describe. The new-input flag (renamed strictInput) now also requires decimal digits; stored schedules keep the lenient reading and run as before, so existing rows are not re-authored mid-tick. Fixes stablyai#49684 Co-authored-by: Afloat16 <[email protected]>
c445ba0 to
d30ddb3
Compare
ELI5
When you type a new cron schedule for an automation, Orca now only accepts plain decimal numbers like
5or*/10. Before, it also quietly accepted JavaScript number spellings like0x10or1e1and ran on a different minute than the cron text says. Schedules you already saved keep running exactly as before.What Changed
isValidAutomationCronScheduleandisValidAutomationScheduleaccepted0x10 * * * *(fires at :16),1e1 * * * *(:10),*/0b10 * * * *(every 2 minutes),+5 * * * *and5.0 * * * *, because each value and step went throughNumber().05 9 1-15/2 JAN-mar MON-fri) are still accepted.rejectOversizedStepis renamedstrictInput(inCronParseOptionsandparseCronField) and now also covers number parsing. A smallparseCronIntegerhelper returnsNaNfor anything other than^\d+$whenstrictInputis set. It is used for range starts and ends and for steps, so the existingNumber.isIntegercheck rejects the value. Month and day names are resolved first, as before.strictInput, so a saved0x10 * * * *still fires at :16 instead of throwing mid-tick.Why
Cron notation only defines decimal integers. Leaving
Number()'s wider grammar in place let a typo or copy-paste save a cadence the user never wrote. Putting the check in the existing new-input mode reuses the boundary that already separates "validate what the user typed" from "keep running what is stored" (#15895), so existing rows do not need to be re-authored. A separaterejectNonDecimalNumbersflag besiderejectOversizedStepwould have duplicated that boundary.Linked Issue
Fixes #49684
Original fix by @Afloat16 in #49720; final version reworked during the bug bash.
Reported by @Afloat16
Visual Proof
N/A: this is a change to the shared schedule parser with no component or layout changes. The only thing a user sees is the existing invalid-schedule refusal, which now also appears for non-decimal cron numbers. Behavior was checked with a parser probe:
0x10,*/0b10,1e1,+5,5.0,0o7,*/2.0,0X1F,1-0x5, a hex month and a binary weekday are all refused as new input after the change, and all were accepted onmain.Testing
Commit
c445ba05405a94ce894b720269ae17df3b941ecepassed the requiredtimeout 900 pnpm check:changed --base=4e43dffdaca90950629735e77ccacb21f2513a1egate on Ubuntu 24.04 / Node 24: 27 checks passed, including formatting, lint, affected unit tests, selected typecheck projects and ratchets. Required changed-code validation. The repository dependency installer and pinned toolchain were used without disabling dependency policy. Upstream workflow approval and the aggregate merge gate remain separate.Earlier focused validation notes:
Repro on
main:isValidAutomationCronSchedule('0x10 * * * *')returnstrue, andparseCronExpression('0x10 * * * *').minutesis{16}.Regression tests in
automation-cron-input-validation.test.ts: five JavaScript-notation inputs are refused by both validators, decimal and named input is still accepted, and a persisted hexadecimal minute still runs at :16 throughisRunnableAutomationScheduleandparseCronExpression.vitest run src/shared/automations/scheduling/passes (40 tests). oxfmt, the anti-slop oxlint, code-quality oxlint, ast-grep and the changed-code quality gate are all clean on the touched files.Platform: macOS (pure TypeScript parser, no platform-specific code).
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
Performance
None that matters. Schedule parsing runs when a schedule is entered or edited, and on scheduler ticks for stored rows. Neither path is hot.
^\d+$test per number token, roughly 0.1 µs per token. A worst-case 400-token field went from about 36 µs to about 44 µs, which is far below a frame.Risk
Level: Low. Only new-input validation is stricter: anyone who types
0x10now gets a refusal instead of a hidden :16 cadence. Saved and provider-owned schedules keep their existing reading. A plain revert restores the old behavior.Review
Self-reviewed for correctness, backward compatibility of stored schedules, and performance.
Existing changes were reviewed by @Afloat16. New-input parsing rejects non-decimal forms while stored schedules keep their previous cadence. The check stays in shared parser code, so agents, integrations, mobile clients and SSH hosts use the same boundary without protocol or credential changes. No UI components change; the per-token regex cost and compatibility behavior are documented above.
Agent skill upstream boundary
Notes
Shared parser used by desktop, mobile and remote paths alike. Stored-schedule behavior is unchanged, so mixed-version clients and SSH hosts agree on existing schedules.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)AI Disclosure
Contribution owner and primary contributor: @Afloat16. GPT-6 Astra Pro was used for implementation support and regression analysis.