You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(cli): refuse impossible calendar dates in automations --by - #50988
If you asked Orca to run an automation "by February 30", Orca quietly moved the deadline to March 2. Now it tells you that date does not exist and saves nothing.
What Changed
Before:orca automations create ... --once --by 2027-02-30T09:00:00+09:00 (and automations watch-pr --by ...) exited 0 and saved once.by = 2027-03-02T00:00:00.000Z. Non-leap Feb 29 became March 1, and April 31 became May 1.
After: both commands fail with the existing invalid_argument error (--by must be a date and time, such as ...) and nothing is created. Real dates, including leap days like 2028-02-29, keep the same timestamps as before.
Mechanism: a new shared helper, hasImpossibleLeadingDate in src/cli/arguments/calendar-date.ts, reads a leading YYYY-MM-DD and builds it again with Date.UTC. If the year, month or day comes back different, the date is impossible. getOnceFlags then treats the value as unparseable. Slack --at and Linear --due-date each had their own copy of this check. Both now use the shared helper, and their behavior stays the same (Linear still refuses years 0000-0099).
Why
Date.parse normalizes out-of-range days into the next month instead of failing, so the old Number.isFinite check never saw the problem. Reading the date back is the check Slack and Linear already used. Sharing it means the three CLI date flags agree, and there is one copy to maintain.
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
Repro: run getOnceFlags with --once --by 2027-02-30T09:00:00+09:00 on main. It returns a March 2 deadline.
New src/cli/automations/automation-once-flag.test.ts fails on main and passes here. It covers non-leap Feb 29, Feb 30, century non-leap 2100-02-29, April 31, and checks that leap day 2104-02-29 is still accepted.
New linear-request-builders.test.ts and slack-action-args.test.ts cover the shared check where those flags use it.
vitest run src/cli/automations src/cli/linear src/cli/slack: 59 passed. oxfmt, oxlint (anti-slop, code-quality native), ast-grep and the changed-code quality gate are clean on the touched files. Tested on macOS. The logic is plain JS date math and is the same on every platform.
Performance
None. The check runs once per CLI invocation, only when the flag is given. It adds about 0.25 µs per --by value (90 ns before, 340 ns after in a microbenchmark), with no I/O, subprocesses or polling.
Risk
Level: Low
Only YYYY-MM-DD values naming a day the month does not have are newly refused. Inputs that don't start with YYYY-MM-DD go through Date.parse unchanged. The check runs in the CLI before any RPC, so the request shape is unchanged for older runtimes and remote hosts. A plain revert backs it out.
No actionable comments were generated in the recent review.
Walkthrough
A shared validator now detects impossible leading calendar dates. Automation deadlines, Linear due dates, and Slack scheduled timestamps use it to reject invalid dates. Tests cover invalid dates in all three input paths and valid leap-day automation deadlines.
Severity of issue fixed: Medium
Merge Risk: Minimal · up to 796c5
The CLI now rejects impossible calendar dates, such as February 30, for automation deadlines, Linear due dates and Slack scheduled times instead of silently rolling them into March. The change is small and reversible, and no merge-blocking risk was found.
Pre-merge checks: 3 · 1
Failed checks: 1 inconclusive
Check name
Status
Explanation
Resolution
Out of Scope Changes check
The whole-PR diff against merge base 02115c6 now includes changes outside the --by path. The helper hasImpossibleLeadingDate is shared. src/cli/linear/linear-request-builders.ts (`getDueDateFla…
Update the PR description to list the Slack --at and Linear --due-date behavior changes, their risk, and their tests. Or move those call-site changes and their tests to a separate PR. Then reassess the scope.
Passed checks: 3 passed
Check name
Status
Explanation
Linked Issues check
[#50967] requires a --by value with a leading YYYY-MM-DD that names a day past the end of its month (February 30, and February 29 in a non-leap year) to fail with an invalid-argument error and creat…
Title check
The title names the actual change: rejecting impossible calendar dates in automation --by values. It uses the conventional fix(cli) prefix and matches the summarized changes in getOnceFlags and the sh…
Description check
The description follows the template and fills in most sections. It has an ELI5, a before/after account with the mechanism, the reason for the shared helper, a linked issue (Fixes #50967), a visual pr…
Full details: Linked Issues check
Explanation
[#50967] requires a --by value with a leading YYYY-MM-DD that names a day past the end of its month (February 30, and February 29 in a non-leap year) to fail with an invalid-argument error and create no automation. The previous review found this met at head 953a7b5 through isPastEndOfMonth in src/cli/automations/automation-once-flag.ts. Since then, head 796c5c5 adds hasImpossibleLeadingDate in src/cli/arguments/calendar-date.ts, and getOnceFlags now calls it before parsing. The change keeps the same invalid-date error path. The change set summary shows no edit that removes the February check from the --by path. The test file still covers February 30, February 29 in 2027, and valid leap-day forms. The reported zero-write runtime results were captured before this refactor, so they do not directly cover head 796c5c5. Based on the source summary, the requirement remains met. I did not reread the final automation-once-flag.ts hunk in full.
Full details: Title check
Explanation
The title names the actual change: rejecting impossible calendar dates in automation --by values. It uses the conventional fix(cli) prefix and matches the summarized changes in getOnceFlags and the shared helper.
Full details: Description check
Explanation
The description follows the template and fills in most sections. It has an ELI5, a before/after account with the mechanism, the reason for the shared helper, a linked issue (Fixes #50967), a visual proof explanation (N/A with reproducible output), testing notes, a performance statement, and a risk level with a revert path. Gaps: the Testing checkboxes are marked but the Review, Agent skill upstream boundary, and AI Disclosure sections are left blank or unchecked, and the Notes section does not cover all listed checks. The Linked Issue section also names a 'Fixes' reference and an upstream PR attribution that are not fully explained. These are non-critical, so the description is mostly complete.
Full details: Out of Scope Changes check
Explanation
The whole-PR diff against merge base 02115c6 now includes changes outside the --by path. The helper hasImpossibleLeadingDate is shared. src/cli/linear/linear-request-builders.ts (getDueDateFlag, --due-date) and src/cli/slack/slack-action-args.ts (scheduledFor, --at) now use it. The Slack change also removes the local realDate helper. Both changes add tests. Objectives state that the commit message describes this sharing of the check with Slack --at and Linear --due-date. The current PR description does not mention these commands, and it describes the change as limited to the shared --by parser. The Slack and Linear behavior changes are therefore supported by the commit intent but not by the current description or the linked issue. They are not demonstrably unrelated. The author should document these behavior changes, or remove them from this PR, to keep the stated scope accurate.
Resolution
Update the PR description to list the Slack --at and Linear --due-date behavior changes, their risk, and their tests. Or move those call-site changes and their tests to a separate PR. Then reassess the 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.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: bb1c8c56-94c0-4773-bb3e-ac8deb1f963a
Commits
Reviewing files that changed from the base of the PR and between 953a7b5 and 796c5c5.
Files selected for processing: 7
src/cli/arguments/calendar-date.ts
src/cli/automations/automation-once-flag.test.ts
src/cli/automations/automation-once-flag.ts
src/cli/linear/linear-request-builders.test.ts
src/cli/linear/linear-request-builders.ts
src/cli/slack/slack-action-args.test.ts
src/cli/slack/slack-action-args.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
Date.parse rolls a day the month does not have into the next month, so
`--by 2027-02-30T09:00:00+09:00` saved a March 2 deadline. A leading
YYYY-MM-DD is now read back through a shared hasImpossibleLeadingDate
check and refused with the existing invalid-argument error. Slack --at
and Linear --due-date reuse the same check instead of their own copies.
Fixesstablyai#50967
Co-authored-by: SeungWoon Song <[email protected]>
nwparker
changed the title
fix(automations): reject --by dates that do not exist on the calendar
fix(cli): refuse impossible calendar dates in automations --by
Nov 27, 2026
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
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.
ELI5
If you asked Orca to run an automation "by February 30", Orca quietly moved the deadline to March 2. Now it tells you that date does not exist and saves nothing.
What Changed
orca automations create ... --once --by 2027-02-30T09:00:00+09:00(andautomations watch-pr --by ...) exited 0 and savedonce.by = 2027-03-02T00:00:00.000Z. Non-leap Feb 29 became March 1, and April 31 became May 1.invalid_argumenterror (--by must be a date and time, such as ...) and nothing is created. Real dates, including leap days like2028-02-29, keep the same timestamps as before.hasImpossibleLeadingDateinsrc/cli/arguments/calendar-date.ts, reads a leadingYYYY-MM-DDand builds it again withDate.UTC. If the year, month or day comes back different, the date is impossible.getOnceFlagsthen treats the value as unparseable. Slack--atand Linear--due-dateeach had their own copy of this check. Both now use the shared helper, and their behavior stays the same (Linear still refuses years 0000-0099).Why
Date.parsenormalizes out-of-range days into the next month instead of failing, so the oldNumber.isFinitecheck never saw the problem. Reading the date back is the check Slack and Linear already used. Sharing it means the three CLI date flags agree, and there is one copy to maintain.Linked Issue
Fixes #50967
Original fix by @SeungWoonSong in #50988; final version reworked during the bug bash.
Visual Proof
N/A: this is a CLI argument-parsing change with no UI. Here is the
getOnceFlagsoutput on main and on this branch:Testing
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
Repro: run
getOnceFlagswith--once --by 2027-02-30T09:00:00+09:00on main. It returns a March 2 deadline.New
src/cli/automations/automation-once-flag.test.tsfails on main and passes here. It covers non-leap Feb 29, Feb 30, century non-leap 2100-02-29, April 31, and checks that leap day 2104-02-29 is still accepted.New
linear-request-builders.test.tsandslack-action-args.test.tscover the shared check where those flags use it.vitest run src/cli/automations src/cli/linear src/cli/slack: 59 passed. oxfmt, oxlint (anti-slop, code-quality native), ast-grep and the changed-code quality gate are clean on the touched files. Tested on macOS. The logic is plain JS date math and is the same on every platform.Performance
None. The check runs once per CLI invocation, only when the flag is given. It adds about 0.25 µs per
--byvalue (90 ns before, 340 ns after in a microbenchmark), with no I/O, subprocesses or polling.Risk
Level: Low
Only
YYYY-MM-DDvalues naming a day the month does not have are newly refused. Inputs that don't start withYYYY-MM-DDgo throughDate.parseunchanged. The check runs in the CLI before any RPC, so the request shape is unchanged for older runtimes and remote hosts. A plain revert backs it out.Notes
Reported by @SeungWoonSong