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(google): refuse impossible calendar dates and clock times in event times - #51166
Asking for a meeting on February 30 quietly put it on March 2, because JavaScript's date parser rolls days a month doesn't have into the next month. Now the calendar commands say the date isn't a real one, the same way automations --by already does. A time like 25:00 now gets a clear message instead of an internal error.
What Changed
parseEventTime (src/main/google/google-event-time.ts) runs hasImpossibleLeadingDate on the trimmed value before anything else and throws a GoogleToolError (--start takes a real calendar date; 2027-02-30 is not one.). For a bare local time it also reads the clock back through Date.parse, so 25:00 / 10:60 get a usage error instead of the RangeError that Intl raised inside zonedInstant. 24:00 is still accepted.
windowBound (src/main/google/google-time-zone.ts) returns null for an impossible day, so --from / --to answer with their existing usage text.
calendar-date.ts moves unchanged from src/cli/arguments to src/shared/validation so the main process can import it; the three CLI importers (automation-once-flag, linear-request-builders, slack-action-args) take the new path.
Before / after (Asia/Shanghai):
input
before
after
--start 2027-02-30T10:00
event at 2027-03-02T02:00:00Z
--start takes a real calendar date; 2027-02-30 is not one.
--start 2027-02-30 (all-day)
Google is sent start.date: "2027-02-30"
same message
list --from 2027-02-30
window starts 2027-02-30T00:00:00+08:00
existing --from usage error
--start 2027-03-05T25:00
RangeError: Invalid time value
--start takes a real clock time; 25:00 is not one.
This covers orca calendar create|update --start/--end (CLI and agent tool) and orca calendar list|suggest-time --from/--to, since they share these parsers.
Why
#50988 added hasImpossibleLeadingDate for automations --by, but the calendar parsers never used it. Reusing it keeps one definition of "a day the calendar has". Moving it to src/shared (rather than listing a src/cli file in config/tsconfig.node.json) avoids making the Electron main process depend on a CLI argument module. The clock check uses Date.parse like the offset branch next to it, which keeps 24:00 valid.
N/A: no UI change. The difference is only the event time sent to Google or the error text a CLI/agent tool call returns, shown in the table above and asserted in the new test.
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
New src/main/google/google-calendar-impossible-date.test.ts calls the real parseEventTime and windowBound with no mocks: 2027-02-30, 2027-02-30T10:00, 2026-02-29 09:00, 2027-04-31T10:00Z throw GoogleToolError while the leap day 2028-02-29T10:00 resolves; 10:60 and 25:00 throw GoogleToolError while 24:00 resolves; windowBound returns null for 2027-02-30 and the zone midnight for 2027-02-28. With the fix reverted all three fail.
Targeted vitest on the rebased commit (fresh main): src/main/google/google-calendar-impossible-date.test.ts plus src/cli/automations, src/cli/linear, src/cli/slack suites: 10 files, 62 tests pass.
CI static gates on the touched files pass: anti-slop oxlint, code-quality oxlint, ast-grep, oxfmt, and the changed-code quality gate.
Platform: macOS (pure string/date logic, no platform-specific code).
Performance
None, because this only runs once per parsed --start/--end/--from/--to flag on a calendar command. Measured the added helper at about 0.24-0.68 µs per call (vs 0.14-0.34 µs for the existing Date.parse), and 13 ns on a 100 KB non-date string because the anchored regex fails on the first character. No rendering, polling, IPC fan-out, I/O or subprocess work is involved.
Risk
Level: Low
Only inputs naming a day the calendar doesn't have, or a clock time that doesn't exist, change behavior: they used to produce a different day or an internal error and now produce a usage error. The helper move is a pure rename with no content change. Back out with a plain revert.
Review
Original fix by @Pr1p in #51166; squashed onto current main with authorship preserved.
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
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Not platform-specific. Mixed-version remote compat is unaffected: no protocol or payload shape changes, only stricter local validation of flag strings.
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)
No actionable comments were generated in the recent review.
Walkthrough
Google calendar event-time parsing now rejects impossible leading dates and invalid clock values in local date-time inputs. Window-bound parsing returns null for impossible leading dates. Tests cover invalid inputs and valid leap-day, 24:00, and Shanghai-midnight cases. Three CLI modules now import the date validator from the shared validation module.
Severity of issue fixed: Medium
Merge Risk: Low · up to 0bfca
Calendar commands now reject impossible dates, but local times with impossible seconds such as :99 can still be accepted. This is a small gap that can be fixed before or after merge.
Pre-merge checks: 4
Check name
Status
Explanation
Linked Issues check
Issue #51161 requires calendar commands to reject impossible dates and invalid clock times with a usage error. At the reviewed head, parseEventTime (src/main/google/google-event-time.ts) calls `ha…
Out of Scope Changes check
All changes support the objective in #51161. google-event-time.ts and google-time-zone.ts hold the validation. calendar-date.ts moves from src/cli/arguments to src/shared/validation with unc…
Title check
The title names the main change: calendar event time parsing now refuses impossible calendar dates and clock times. It matches the changeset (google-event-time.ts, google-time-zone.ts, and the new val…
Description check
The description follows the template and fills in every required section. It has ELI5, What Changed, Why, a linked issue (Fixes #51161), a Visual Proof N/A with reason, Testing, Performance, Risk with…
Full details: Linked Issues check
Explanation
Issue #51161 requires calendar commands to reject impossible dates and invalid clock times with a usage error. At the reviewed head, parseEventTime (src/main/google/google-event-time.ts) calls hasImpossibleLeadingDate before any other branch. It throws GoogleToolError for 2027-02-30T10:00 and for all-day 2027-02-30. The DAY branch now runs after that check, so an invalid all-day date no longer reaches Google as start.date. The local branch reads the clock back through Date.parse(${date}T${time}:00Z) and throws GoogleToolError for 25:00 and 10:60, which prevents the RangeError from Intl in zonedInstant. 24:00 still passes this check. The helper body in src/shared/validation/calendar-date.ts was read at head: it compares the Date.UTC read-back to year, month, and day, so Feb 30 and Apr 31 are refused and Feb 29 in a leap year is accepted. Per the PR summary, windowBound (src/main/google/google-time-zone.ts) returns null for an impossible leading date. I did not re-read the windowBound diff in this pass; that part rests on the raw summary and the previous assessment. The new test file covers these cases without mocks.
Full details: Out of Scope Changes check
Explanation
All changes support the objective in #51161. google-event-time.ts and google-time-zone.ts hold the validation. calendar-date.ts moves from src/cli/arguments to src/shared/validation with unchanged content. The move is needed because the main-process tsconfig cannot import src/cli files (TS6307), and the main process now imports the helper. The three CLI importers (automation-once-flag, linear-request-builders, slack-action-args) change only their import path. The new test file exercises the changed parsers. No unrelated behavior change appears in the diffs read or in the summary.
Full details: Title check
Explanation
The title names the main change: calendar event time parsing now refuses impossible calendar dates and clock times. It matches the changeset (google-event-time.ts, google-time-zone.ts, and the new validation). It uses the conventional commit form and fits in one sentence.
Full details: Description check
Explanation
The description follows the template and fills in every required section. It has ELI5, What Changed, Why, a linked issue (Fixes #51161), a Visual Proof N/A with reason, Testing, Performance, Risk with level Low, and the checklists. It explains the mechanism, the before/after behavior, and the rollback path. The AI Disclosure section is blank, but the template says to skip it for internal contributors, so this is acceptable.
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: f3592feb-e077-41f0-84e4-269654a868ea
Commits
Reviewing files that changed from the base of the PR and between 65542fc and 0bfca11.
Files selected for processing: 3
src/main/google/google-event-time.ts
src/main/google/google-time-zone.ts
src/shared/validation/calendar-date.ts
Files with no reviewable changes: 1
src/shared/validation/calendar-date.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Validate optional seconds before accepting a local clock.
For 2027-03-05T10:00:99, LOCAL matches but captures only 10:00. This check validates 10:00:00, and zonedInstant returns a successful result. The impossible seconds never reach validation.
Validate the complete matched clock, including optional seconds. Keep valid 10:00 and 24:00 inputs accepted.
Based on learnings, clock-range validation must cover all accepted clock fields.
Calendar --start/--end and --from/--to passed dates like 2027-02-30
through Date.parse, which rolled them into the next month (or sent the
raw invalid day to Google). They now reuse hasImpossibleLeadingDate and
answer with a usage error. A local clock like 25:00 or 10:60 also gets
a usage error instead of an Intl RangeError; 24:00 is still accepted.
The helper moves from src/cli/arguments to src/shared/validation so the
main process can import it; the three CLI importers take the new path.
Fixesstablyai#51161
Co-authored-by: Neil <[email protected]>
nwparker
changed the title
fix(google): refuse impossible calendar dates in event times
fix(google): refuse impossible calendar dates and clock times in event times
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
Asking for a meeting on February 30 quietly put it on March 2, because JavaScript's date parser rolls days a month doesn't have into the next month. Now the calendar commands say the date isn't a real one, the same way
automations --byalready does. A time like25:00now gets a clear message instead of an internal error.What Changed
parseEventTime(src/main/google/google-event-time.ts) runshasImpossibleLeadingDateon the trimmed value before anything else and throws aGoogleToolError(--start takes a real calendar date; 2027-02-30 is not one.). For a bare local time it also reads the clock back throughDate.parse, so25:00/10:60get a usage error instead of theRangeErrorthatIntlraised insidezonedInstant.24:00is still accepted.windowBound(src/main/google/google-time-zone.ts) returnsnullfor an impossible day, so--from/--toanswer with their existing usage text.calendar-date.tsmoves unchanged fromsrc/cli/argumentstosrc/shared/validationso the main process can import it; the three CLI importers (automation-once-flag,linear-request-builders,slack-action-args) take the new path.Before / after (
Asia/Shanghai):--start 2027-02-30T10:002027-03-02T02:00:00Z--start takes a real calendar date; 2027-02-30 is not one.--start 2027-02-30(all-day)start.date: "2027-02-30"list --from 2027-02-302027-02-30T00:00:00+08:00--fromusage error--start 2027-03-05T25:00RangeError: Invalid time value--start takes a real clock time; 25:00 is not one.This covers
orca calendar create|update --start/--end(CLI and agent tool) andorca calendar list|suggest-time --from/--to, since they share these parsers.Why
#50988 added
hasImpossibleLeadingDateforautomations --by, but the calendar parsers never used it. Reusing it keeps one definition of "a day the calendar has". Moving it tosrc/shared(rather than listing asrc/clifile inconfig/tsconfig.node.json) avoids making the Electron main process depend on a CLI argument module. The clock check usesDate.parselike the offset branch next to it, which keeps24:00valid.Linked Issue
Fixes #51161
Visual Proof
N/A: no UI change. The difference is only the event time sent to Google or the error text a CLI/agent tool call returns, shown in the table above and asserted in the new test.
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
New
src/main/google/google-calendar-impossible-date.test.tscalls the realparseEventTimeandwindowBoundwith no mocks:2027-02-30,2027-02-30T10:00,2026-02-29 09:00,2027-04-31T10:00ZthrowGoogleToolErrorwhile the leap day2028-02-29T10:00resolves;10:60and25:00throwGoogleToolErrorwhile24:00resolves;windowBoundreturnsnullfor2027-02-30and the zone midnight for2027-02-28. With the fix reverted all three fail.Targeted vitest on the rebased commit (fresh
main):src/main/google/google-calendar-impossible-date.test.tsplussrc/cli/automations,src/cli/linear,src/cli/slacksuites: 10 files, 62 tests pass.CI static gates on the touched files pass: anti-slop oxlint, code-quality oxlint, ast-grep, oxfmt, and the changed-code quality gate.
Platform: macOS (pure string/date logic, no platform-specific code).
Performance
None, because this only runs once per parsed
--start/--end/--from/--toflag on a calendar command. Measured the added helper at about 0.24-0.68 µs per call (vs 0.14-0.34 µs for the existingDate.parse), and 13 ns on a 100 KB non-date string because the anchored regex fails on the first character. No rendering, polling, IPC fan-out, I/O or subprocess work is involved.Risk
Level: Low
Only inputs naming a day the calendar doesn't have, or a clock time that doesn't exist, change behavior: they used to produce a different day or an internal error and now produce a usage error. The helper move is a pure rename with no content change. Back out with a plain revert.
Review
Original fix by @Pr1p in #51166; squashed onto current
mainwith authorship preserved.Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Not platform-specific. Mixed-version remote compat is unaffected: no protocol or payload shape changes, only stricter local validation of flag strings.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)