fix(frontend): union day-of-month and day-of-week in cron next-runs preview#4798
fix(frontend): union day-of-month and day-of-week in cron next-runs preview#4798ardaerzin wants to merge 1 commit into
Conversation
…review The schedule drawer's 'next runs' preview ANDed the day-of-month and day-of-week cron fields, so an expression like `0 0 1 * 1` only matched when the 1st of the month was also a Monday — previewing the next run as 2027-02-01 instead of the coming Monday. POSIX cron and the backend croniter treat the two fields as a union when both are restricted, so the preview disagreed with what the schedule actually fires. Match either field when both are restricted (plain AND otherwise, since a `*` field is always-true). Add unit coverage for the union case and for the single-restricted-field AND case.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Railway Preview Environment
|
Stacked on #4749 (
gateway-triggers-all). solves a bug in the schedule drawer's cron preview.Problem
The schedule "next runs" preview ANDs the day-of-month and day-of-week cron fields. POSIX cron — and the backend
croniterthat actually fires the schedule — treat them as a union when both are restricted.So
0 0 1 * 1("1st of the month or any Monday") previewed its next run as 2027-02-01 (the next 1st-of-month that also happens to be a Monday, ~7 months out) instead of the coming Monday. The preview disagreed with what the schedule would actually doBefore / After
For
0 0 1 * 1, evaluated 2026-06-22 (a Monday):Change
nextCronRunsnow matches either day field when both are restricted, and keeps plain AND when only one is (a*field is always-true). Pure client-side preview helper — the backend remains the source of truth; this only makes the hint agree with it.Added unit coverage for the union case and the single-restricted-field AND case (
gatewayTriggerCron.test.ts, 13 passing).Verified
vitest run gatewayTriggerCron.test.ts— 13/13 pass