Skip to content

fix(automations): require decimal cron numbers in new schedule input - #49720

Merged
nwparker merged 1 commit into
stablyai:mainfrom
Afloat16:fix/cron-decimal-input
Nov 26, 2026
Merged

nwparker merged 1 commit into
stablyai:mainfrom
Afloat16:fix/cron-decimal-input

Conversation

@Afloat16

@Afloat16 Afloat16 commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

When you type a new cron schedule for an automation, Orca now only accepts plain decimal numbers like 5 or */10. Before, it also quietly accepted JavaScript number spellings like 0x10 or 1e1 and ran on a different minute than the cron text says. Schedules you already saved keep running exactly as before.

What Changed

  • Before: isValidAutomationCronSchedule and isValidAutomationSchedule accepted 0x10 * * * * (fires at :16), 1e1 * * * * (:10), */0b10 * * * * (every 2 minutes), +5 * * * * and 5.0 * * * *, because each value and step went through Number().
  • After: those inputs fail new-input validation, so the schedule field shows the usual invalid-schedule refusal. Decimal and named values (05 9 1-15/2 JAN-mar MON-fri) are still accepted.
  • Mechanism: the existing new-input flag rejectOversizedStep is renamed strictInput (in CronParseOptions and parseCronField) and now also covers number parsing. A small parseCronInteger helper returns NaN for anything other than ^\d+$ when strictInput is set. It is used for range starts and ends and for steps, so the existing Number.isInteger check rejects the value. Month and day names are resolved first, as before.
  • Stored and provider-owned schedules are parsed without strictInput, so a saved 0x10 * * * * 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 separate rejectNonDecimalNumbers flag beside rejectOversizedStep would 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 on main.

Testing

Commit c445ba05405a94ce894b720269ae17df3b941ece passed the required timeout 900 pnpm check:changed --base=4e43dffdaca90950629735e77ccacb21f2513a1e gate 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.

  • Required changed-code gate passed on the commit linked above.
  • Full upstream aggregate CI passes.

Earlier focused validation notes:

  • Repro on main: isValidAutomationCronSchedule('0x10 * * * *') returns true, and parseCronExpression('0x10 * * * *').minutes is {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 through isRunnableAutomationSchedule and parseCronExpression.

  • 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.

  • Stored rows (lenient path): the only change is one extra boolean check per token. A side-by-side micro-benchmark showed no difference beyond noise (about 230 ns per field in both versions).
  • New input (strict path): one ^\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.
  • No I/O, no subprocesses and no new polling.

Risk

Level: Low. Only new-input validation is stricter: anyone who types 0x10 now 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

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

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

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • I stated the risk: what could break, for whom, and how to back it out
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (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.

@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8ff1d7ae-138a-4c0f-9d32-2a38295c05f4
Commits

Reviewing files that changed from the base of the PR and between c445ba0 and d30ddb3.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

Cron parsing adds an opt-in setting that rejects non-decimal numeric field values and explicit steps. New-input schedule validation enables this setting for all cron fields. Named values remain accepted. Existing parsing retains its default numeric conversion behavior, including hexadecimal input.

Severity of issue fixed: Medium

Merge Risk: Minimal · previous review c445b

New cron schedules now reject JavaScript-style numeric notation such as 0x10, 1e1 and 0b10, while stored schedules keep their existing interpretation. No merge-blocking risk was found; CI should confirm the full test run.

Pre-merge checks: Passed 4

Check name Status Explanation
Linked Issues check Passed [#49684] requires new cron input to reject JavaScript numeric notation (0x10, 1e1, */0b10) and to keep decimal, named, and stored schedules unchanged. At the reviewed head, the option renamed from rej…
Out of Scope Changes check Passed All source changes support the #49684 requirement or its existing #15895 step-bound behavior. The rename from rejectOversizedStep to strictInput carries the new-input gate through parseCronField, pars…
Title check Passed The title "fix(automations): require decimal cron numbers in new schedule input" matches the main change. The PR makes new-input cron validation reject JavaScript-style numerics such as 0x10, 1e1, and…
Description check Passed The description follows the repository template and covers the required sections. The ELI5, What Changed, Why, Linked Issue (Fixes #49684), Visual Proof (N/A with a reason), Testing, Performance, Risk…
Full details: Linked Issues check

Explanation

[#49684] requires new cron input to reject JavaScript numeric notation (0x10, 1e1, */0b10) and to keep decimal, named, and stored schedules unchanged. At the reviewed head, the option renamed from rejectOversizedStep to strictInput. parseCronInteger returns NaN when strictInput is set and the token does not match /^\d+$/. parseCronNumber and the step path both call it, so 0x10, 1e1, and */0b10 throw 'Invalid cron ...'. The test file adds cases for 0x10, 1e1, */0b10, +5, and 5.0 through isValidAutomationCronSchedule and isValidAutomationSchedule. Decimal and named input (05 9 1-15/2 JAN-mar MON-fri) remains accepted. parseCronExpression defaults strictInput to false, and isRunnableAutomationSchedule does not pass it, so stored hexadecimal schedules keep Number() coercion (0x10 maps to minute 16). The renamed option is forwarded from parseSchedule through the cron branch. That forwarding line is unchanged in the diff. Its prior use with rejectOversizedStep implies the option object passes through. The test file was not executed by the author, and I did not run it. The verdict rests on source inspection of the whole-PR diff.

Full details: Out of Scope Changes check

Explanation

All source changes support the #49684 requirement or its existing #15895 step-bound behavior. The rename from rejectOversizedStep to strictInput carries the new-input gate through parseCronField, parseCronExpression, getAutomationScheduleInputError, and isValidAutomationCronSchedule. The oversized-step check now applies to the same strict path and keeps its prior behavior. The added helper parseCronInteger and the strictInput parameter on parseCronNumber implement the numeric rejection. The test file adds coverage for the linked reproductions and the stored hexadecimal control. Remaining uncertainty: parseCronField now requires strictInput. Any caller outside the reviewed diff that omits this argument would fail typecheck. I could not search the repository for other callers, so this compile-time risk is not fully established. It does not change the requirement verdict.

Full details: Title check

Explanation

The title "fix(automations): require decimal cron numbers in new schedule input" matches the main change. The PR makes new-input cron validation reject JavaScript-style numerics such as 0x10, 1e1, and */0b10, and renames rejectOversizedStep to strictInput. The title is specific and concise, and it names the scope and the behavior change.

Full details: Description check

Explanation

The description follows the repository template and covers the required sections. The ELI5, What Changed, Why, Linked Issue (Fixes #49684), Visual Proof (N/A with a reason), Testing, Performance, Risk (Level: Low, with a revert path), Review, Agent skill upstream boundary, Notes, and Checklist sections are all filled in with specific content. It explains the before and after behavior, the mechanism (renaming rejectOversizedStep to strictInput and adding a parseCronInteger helper), and the compatibility guarantee for stored schedules. Testing is well documented with a CI run link and local validation notes. The AI Disclosure section is filled in, which the template only asks for outside contributors. Two items are unresolved: the 'Full upstream aggregate CI passes' box is unchecked, and the Review section is thin on the reviewer-facing details. Neither is critical for a PR of this scope.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b92c319c-6269-4f7e-89a1-cb24fc4c8ccd
Commits

Reviewing files that changed from the base of the PR and between 1a1092a and c445ba0.

Files selected for processing: 3

  • src/shared/automations/scheduling/automation-cron-field-parsing.ts
  • src/shared/automations/scheduling/automation-cron-input-validation.test.ts
  • src/shared/automations/scheduling/automation-schedule-parsing.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@nwparker
nwparker force-pushed the fix/cron-decimal-input branch from 1a1092a to c445ba0 Compare November 26, 2026 11:22
@nwparker nwparker changed the title fix(automations): reject non-decimal tokens in new cron schedules fix(automations): require decimal cron numbers in new schedule input Nov 26, 2026
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]>
@nwparker
nwparker force-pushed the fix/cron-decimal-input branch from c445ba0 to d30ddb3 Compare November 26, 2026 14:26
@nwparker
nwparker merged commit 14d64e1 into stablyai:main Nov 26, 2026
57 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: New cron input accepts JavaScript numeric notation

2 participants