Skip to content

fix(cli): refuse impossible calendar dates in automations --by - #50988

Merged
nwparker merged 1 commit into
stablyai:mainfrom
SeungWoonSong:fix/automations-by-invalid-calendar-date
Nov 27, 2026
Merged

nwparker merged 1 commit into
stablyai:mainfrom
SeungWoonSong:fix/automations-by-invalid-calendar-date

Conversation

@SeungWoonSong

@SeungWoonSong SeungWoonSong commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

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

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

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 getOnceFlags output on main and on this branch:

# origin/main
--once --by 2027-02-30T09:00:00+09:00  =>  accepted -> 2027-03-02T00:00:00.000Z
--once --by 2027-02-29T09:00:00+09:00  =>  accepted -> 2027-03-01T00:00:00.000Z
--once --by 2101-04-31 09:00           =>  accepted -> 2101-05-01T16:00:00.000Z
--once --by 2028-02-29                 =>  accepted -> 2028-02-29T00:00:00.000Z
--once --by 2027-11-06T17:00:00-05:00  =>  accepted -> 2027-11-06T22:00:00.000Z
# this branch
--once --by 2027-02-30T09:00:00+09:00  =>  refused (invalid_argument)
--once --by 2027-02-29T09:00:00+09:00  =>  refused (invalid_argument)
--once --by 2101-04-31 09:00           =>  refused (invalid_argument)
--once --by 2028-02-29                 =>  accepted -> 2028-02-29T00:00:00.000Z
--once --by 2027-11-06T17:00:00-05:00  =>  accepted -> 2027-11-06T22:00:00.000Z

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

Notes

Reported by @SeungWoonSong

@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

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: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Out of Scope Changes check Inconclusive 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 Passed checks: 3 passed

Check name Status Explanation
Linked Issues check Passed [#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 Passed 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 Passed 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.

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

Fixes stablyai#50967

Co-authored-by: SeungWoon Song <[email protected]>
@nwparker
nwparker force-pushed the fix/automations-by-invalid-calendar-date branch from 953a7b5 to 796c5c5 Compare November 27, 2026 16:15
@nwparker 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
@nwparker
nwparker merged commit b5a2e22 into stablyai:main Nov 27, 2026
59 of 60 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]: automations --by accepts February 29 in a non-leap year and February 30

2 participants