Skip to content

fix(google): refuse impossible minutes in suggest-time --hours - #51196

Merged
nwparker merged 2 commits into
stablyai:mainfrom
Pr1p:fix/calendar-suggest-hours-minutes
Nov 27, 2026
Merged

nwparker merged 2 commits into
stablyai:mainfrom
Pr1p:fix/calendar-suggest-hours-minutes

Conversation

@Pr1p

@Pr1p Pr1p commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

ELI5

orca calendar suggest-time --hours 09:75-17:00 crashed with an internal error after asking Google for free/busy times. The range check let minutes up to 99 through. Now such a range gets the same usage message as any other bad --hours.

What Changed

  • parseHours (src/main/google/google-calendar-free-time.ts) takes minutes 00–59 instead of any two digits.
  • Before: --hours 09:75-17:00 matched, the two Google requests ran, then zonedInstant raised RangeError: Invalid time value.
  • After: --hours takes a range like 09:00-17:00., before any request is made.

24:00 as the end of the range, and one-digit hours like 9:00, still work.

Why

The pattern was the only check on the minutes; what followed compared the padded strings (from >= to, to > '24:00'), which says nothing about 75. Intl throws on a wall clock that does not exist, so the value has to be refused before it gets there.

Linked Issue

Fixes #51189

Visual Proof

N/A: no UI change. The difference is the error text on the command line.

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

google-calendar-free-time.test.ts (new) calls the real suggestCalendarTime with an in-memory GoogleApi (calendar lookup and one free/busy answer). It checks that 09:75-17:00 and 09:00-17:60 reject with GoogleToolError, and that 9:00-24:00 still resolves to { from: '09:00', to: '24:00' }. This is an input-parsing boundary, which the repo rules allow a test for.

With the change reverted the test fails with expected error to be instance of GoogleToolError; the rejection was RangeError.

pnpm check:changed: all 27 checks pass.

Performance

None: the same single regex match with a narrower class.

Risk

Level: Low

Only --hours values with minutes above 59 change behavior: an internal error becomes the usage error. Back out with a plain revert.

AI Disclosure

Found, implemented and verified with Claude Code; I reviewed the diff and the test output.

Review

Nothing to flag. The sibling for --start / --end clock times is #51166.

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.

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)

🤖 Generated with Claude Code

`orca calendar suggest-time --hours 09:75-17:00` matched the --hours pattern,
whose minutes ran to 99. The bound then reached zonedInstant, where Intl
throws "RangeError: Invalid time value" after the free/busy request, instead
of the usage text. Minutes are now 00-59 like the other clock inputs.

Co-Authored-By: Claude <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The parseHours function now accepts minute values from 00 through 59. Invalid minute values reach the existing invalid-hours error path. Tests cover rejection of 09:75-17:00 and 09:00-17:60, and normalization of 9:00-24:00.

Severity of issue fixed: Medium

Merge Risk: Minimal · up to 18b79

Impossible minute values in --hours ranges now produce the usage message before any calendar request, instead of failing later with a RangeError. Valid ranges, including 24:00 as the end and one-digit hours, behave as before. The change is small, tested, and easy to revert.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: --hours in suggest-time now refuses impossible minute values. It also names the affected area (google) and the fix type. It matches the parseHours change and the o…
Description check Passed The description follows the template and fills the key sections. The ELI5, What Changed, Why, Linked Issue (Fixes #51189), Visual Proof (N/A with reason), Testing, Performance, Risk (Low, with revert …
Linked Issues check Passed Issue #51189 requires that --hours ranges with impossible minutes (for example 09:75-17:00) receive the existing usage text, --hours takes a range like 09:00-17:00., and not a RangeError after…
Out of Scope Changes check Passed The PR description and the raw summary list two changed files: parseHours in src/main/google/google-calendar-free-time.ts (about +3/-1 lines) and the new `src/main/google/google-calendar-free-time…
Full details: Title check

Explanation

The title names the main change: --hours in suggest-time now refuses impossible minute values. It also names the affected area (google) and the fix type. It matches the parseHours change and the objectives.

Full details: Description check

Explanation

The description follows the template and fills the key sections. The ELI5, What Changed, Why, Linked Issue (Fixes #51189), Visual Proof (N/A with reason), Testing, Performance, Risk (Low, with revert path), AI Disclosure, and Checklist sections are complete. The Review section and the Agent skill boundary are also filled. The Performance line completes the required sentence. The Testing section cites the new test and its revert result. The Linked Issue section uses a real issue number.

Full details: Linked Issues check

Explanation

Issue #51189 requires that --hours ranges with impossible minutes (for example 09:75-17:00) receive the existing usage text, --hours takes a range like 09:00-17:00., and not a RangeError after the free/busy request. At the reviewed head (18b79f9), parseHours in src/main/google/google-calendar-free-time.ts matches minutes with ([0-5]\d). Values such as 75 and 60 no longer match, so parseHours throws GoogleToolError with the required text before pickCalendar and api.send run. The to &gt; '24:00' check still refuses hours above 24. The new test google-calendar-free-time.test.ts checks that 09:75-17:00 and 09:00-17:60 reject with GoogleToolError. It also checks that 9:00-24:00 resolves to { from: '09:00', to: '24:00' }, which covers the supported 24:00 end and one-digit hours. The whole-PR diff could not be read because changed blobs are missing from the checkout. The before-state therefore relies on the PR text and the issue text. The head source and test files were read directly and support the result.

Full details: Out of Scope Changes check

Explanation

The PR description and the raw summary list two changed files: parseHours in src/main/google/google-calendar-free-time.ts (about +3/-1 lines) and the new src/main/google/google-calendar-free-time.test.ts (+41/-0). Both files were read at the reviewed head. The source change is the regex narrowing that fixes #51189. The test exercises the same parser boundary and the supported 9:00-24:00 input. Neither file contains changes beyond the --hours validation and its test. The whole-PR diff and full changed-file list could not be confirmed, because the diff tool returned no text and the file listing was truncated. This leaves a small uncertainty about unlisted files. No evidence of unrelated changes was found.

  • 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: 59a09e7f-db17-421d-aa91-11e037281192
Commits

Reviewing files that changed from the base of the PR and between 758aad9 and 18b79f9.

Files selected for processing: 1

  • src/main/google/google-calendar-free-time.ts
Files with no reviewable changes: 1

  • src/main/google/google-calendar-free-time.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.

@nwparker
nwparker merged commit 310f91c into stablyai:main Nov 27, 2026
55 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]: calendar suggest-time fails with a RangeError for an --hours range with impossible minutes

2 participants