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-calendar): resolve calendar names across all calendarList pages - #50512
Google sends your calendar list in pages of 250. Orca only read the first page, so a calendar further down the list could not be found by name, and if two calendars had the same name across pages Orca quietly picked the first one instead of asking which one you meant. Now Orca reads every page (up to 20 pages, about 5,000 calendars). If the list is still longer than that, Orca says the list is incomplete and asks for a calendar id instead of guessing from part of the list.
What Changed
Before:listCalendarEntries in src/main/google/google-calendar-read.ts requested one calendarList page (maxResults=250) and ignored nextPageToken. With more than 250 calendars:
pickCalendar threw No calendar is named "..." for a calendar on page 2 or later, and orca calendar list --calendars left those calendars out.
A name on page 1 that also appeared on a later page was not reported as ambiguous. The page-1 calendar was returned, so event creates/updates (google-calendar-write.ts, google-calendar-event-target.ts) could go to the wrong calendar.
After:CalendarListSchema parses nextPageToken, and listCalendarEntries follows it until no token is returned, bounded at 20 pages. If a token remains after 20 pages, it throws a GoogleToolError saying the listing is incomplete, so name resolution and listCalendars never act on a partial list. Lookups by calendar id or primary skip the listing and are unchanged.
Why
Google's calendarList.list returns nextPageToken until the last page; following it is the only way to see the full list. The loop mirrors the existing paging in google-calendar-changes.ts and google-gmail-changes.ts. The page cap keeps a misbehaving or huge account from issuing unbounded requests, and failing loudly at the cap is safer than resolving a name against a truncated list.
...exceeds the 20-page limit, so the listing is incomplete. Pass a calendar id instead of a name.
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-list-pagination.test.ts drives the real googleApi + pickCalendar/listCalendars with a stubbed HTTP layer:
two pages: a name on page 2 resolves (case-insensitively) and a name duplicated across pages is refused with the full ambiguity message;
never-ending pages: name lookup and listCalendars both reject as incomplete, while id and primary lookups still resolve.
Reproduced the bug by running the new test against main's google-calendar-read.ts: both cases fail; with this change both pass.
vitest --config config/vitest.config.ts src/main/google: 9 files, 58 tests pass on the rebased commit.
Touched files pass oxfmt, oxlint, anti-slop oxlint, native code-quality oxlint, ast-grep, and the changed-code quality gate.
Platforms: macOS (unit level). The code is platform-neutral async network I/O.
Performance
None on any hot path: this only runs when a user runs a calendar command (orca calendar list/get/create/update, free-time) and is never polled; the trigger checker uses google-calendar-changes.ts, not this code. No new sync I/O or subprocesses, and no renderer/store changes. Benchmark with stubbed HTTP, 250 entries per page:
Typical (1 page): ~0.3 ms average old and new, 1 request. No change.
20 pages (5,000 calendars): ~4-5 ms average, 20 requests (main made 1 request but returned a wrong/incomplete answer).
25 pages (adversarial): the cap holds it to 20 requests (~4.8 ms average) vs ~10.7 ms / 25 requests uncapped.
All waits are async, so nothing blocks the main process; the extra cost is only the network round trips needed for a correct answer.
Risk
Level: Low
The riskiest part is extra requests for users with more than 250 calendars; each request keeps the existing per-request timeout. A name that used to resolve silently to the wrong calendar now returns an "ambiguous" error asking for the calendar id. Past the 20-page cap, listing and name lookup fail explicitly instead of returning partial results. Id and primary lookups are unchanged. No saved-data or wire-format change; back out with a plain revert.
Review
Fix by @Afloat16. Maintainer pass: squashed onto current main as a single commit with authorship preserved; diff is identical to the reviewed change.
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
Security: no new endpoints; it calls the same googleapis calendarList URL with a pageToken parameter set via URLSearchParams. Cross-platform: pure TS, no paths or shell. Remote SSH and mobile go through the existing RPC entry points; response shape is unchanged, so older clients are unaffected.
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)
Review was skipped as selected files did not have any reviewable changes.
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: 84d36274-e574-4c41-a73d-2841052dbe80
Commits
Reviewing files that changed from the base of the PR and between 0f61ee8 and acf32a1.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
Calendar listing now follows continuation tokens and accumulates results across pages, up to 20 pages. The tests check selection of a calendar on the second page, rejection of an ambiguous name with both matching calendar IDs, and behavior when the listing remains incomplete.
Severity of issue fixed: Medium
Merge Risk: Minimal · previous review 0f61e
Calendar listing and name lookup now follow all pages up to a 20-page cap and fail explicitly if the list is incomplete. ID and primary lookups are unchanged. No merge-blocking risk is evident.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: name resolution for Google Calendar now covers all calendarList pages. It matches the raw summary, which describes following nextPageToken in listCalendarEntries and n…
Linked Issues check
Issue #50511 requires: (1) following calendarList continuation tokens so later-page calendars resolve by name; (2) refusing a duplicate name that appears on a later page as ambiguous; (3) keeping dire…
Out of Scope Changes check
The changes are limited to src/main/google/google-calendar-read.ts (calendar-list paging, cap handling, and name lookup) and the new test file src/main/google/google-calendar-list-pagination.test.ts. …
Description check
The description follows the repository template closely. It has ELI5, What Changed, Why, Linked Issue (Fixes #50511), Visual Proof (N/A with a reason and before/after table), Testing, Performance, Ris…
Full details: Title check
Explanation
The title names the main change: name resolution for Google Calendar now covers all calendarList pages. It matches the raw summary, which describes following nextPageToken in listCalendarEntries and name-based lookups. The title is 74 characters, within a typical length, and uses the conventional fix(scope) prefix.
Full details: Linked Issues check
Explanation
Issue #50511 requires: (1) following calendarList continuation tokens so later-page calendars resolve by name; (2) refusing a duplicate name that appears on a later page as ambiguous; (3) keeping direct ID and primary lookups and the existing ambiguity refusal; (4) one-page case-insensitive names still resolving. At head 0f61ee8, listCalendarEntries in src/main/google/google-calendar-read.ts sets maxResults to 250 and follows nextPageToken into pageToken for up to MAX_CALENDAR_LIST_PAGES (20). pickCalendar and listCalendars both use this helper. Name matching lowercases both sides. The primary and @ branch still performs a single calendarList/{id} lookup. The test file google-calendar-list-pagination.test.ts at head covers requirements (1) and (2) in its first case: 'boardroom' resolves to [email protected] on page two, and 'Planning' across pages is refused with both IDs. Its second case covers the new cap behavior and confirms ID and primary lookups still succeed. The one-page case-insensitive case is exercised by the lowercase comparison; the page-two case also needs case-insensitive matching. The incremental change, the cap-exceeded error, is verified from the head file content, not from a diff. The base diff could not be read, so no before/after comparison of this file is available. Requirements are met at head.
Full details: Out of Scope Changes check
Explanation
The changes are limited to src/main/google/google-calendar-read.ts (calendar-list paging, cap handling, and name lookup) and the new test file src/main/google/google-calendar-list-pagination.test.ts. Both connect directly to issue #50511. The change since the previous review makes listCalendarEntries throw a GoogleToolError when the 20-page cap leaves a nextPageToken. This affects name lookups and listCalendars. It is the incomplete-result safeguard named in the PR objectives, and it stays in the paging code path. No unrelated production change appears in the head file. The PR description still says calendars past the cap are silently left unread. This statement is outdated, and the code now reports an error. The description mismatch is not an out-of-scope change.
Full details: Description check
Explanation
The description follows the repository template closely. It has ELI5, What Changed, Why, Linked Issue (Fixes #50511), Visual Proof (N/A with a reason and before/after table), Testing, Performance, Risk (Level: Low, with a backout plan), Agent skill upstream boundary, Notes, and Checklist. It explains the before and after behavior and the mechanism, which is a bounded nextPageToken loop with a 20-page cap that throws an incomplete-list error. The Performance section gives a measured rationale. The AI Disclosure section is absent. The template says to skip it for StablyAI team members, and the author's affiliation is not stated, so it may need to be filled in. The description also includes extended review and CI-validation notes that go beyond the template, but those do not reduce its completeness.
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.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
nwparker
changed the title
fix(google-calendar): resolve calendar names across list pages
fix(google-calendar): resolve calendar names across all calendarList pages
Nov 27, 2026
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
…pages
listCalendarEntries read only the first calendarList page (250 items) and
ignored nextPageToken, so names on later pages failed to resolve and
duplicates across pages silently picked the page-1 calendar. Follow
nextPageToken up to 20 pages and fail explicitly if the list is still
incomplete, so name resolution never uses a partial list.
Fixesstablyai#50511
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
Google sends your calendar list in pages of 250. Orca only read the first page, so a calendar further down the list could not be found by name, and if two calendars had the same name across pages Orca quietly picked the first one instead of asking which one you meant. Now Orca reads every page (up to 20 pages, about 5,000 calendars). If the list is still longer than that, Orca says the list is incomplete and asks for a calendar id instead of guessing from part of the list.
What Changed
listCalendarEntriesinsrc/main/google/google-calendar-read.tsrequested onecalendarListpage (maxResults=250) and ignorednextPageToken. With more than 250 calendars:pickCalendarthrewNo calendar is named "..."for a calendar on page 2 or later, andorca calendar list --calendarsleft those calendars out.google-calendar-write.ts,google-calendar-event-target.ts) could go to the wrong calendar.CalendarListSchemaparsesnextPageToken, andlistCalendarEntriesfollows it until no token is returned, bounded at 20 pages. If a token remains after 20 pages, it throws aGoogleToolErrorsaying the listing is incomplete, so name resolution andlistCalendarsnever act on a partial list. Lookups by calendar id orprimaryskip the listing and are unchanged.Why
Google's
calendarList.listreturnsnextPageTokenuntil the last page; following it is the only way to see the full list. The loop mirrors the existing paging ingoogle-calendar-changes.tsandgoogle-gmail-changes.ts. The page cap keeps a misbehaving or huge account from issuing unbounded requests, and failing loudly at the cap is safer than resolving a name against a truncated list.Linked Issue
Fixes #50511
Visual Proof
N/A. This changes the data returned by calendar CLI/RPC commands, not any UI. Before/after on the same two-page fixture:
pickCalendar(api, 'boardroom'), calendar on page 2GoogleToolError: No calendar is named "boardroom"[email protected]pickCalendar(api, 'Planning'), on page 1 and page 2Several calendars are named "Planning"; pass one's id: [email protected], [email protected]....exceeds the 20-page limit, so the listing is incomplete. Pass a calendar id instead of a name.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-list-pagination.test.tsdrives the realgoogleApi+pickCalendar/listCalendarswith a stubbed HTTP layer:listCalendarsboth reject as incomplete, while id andprimarylookups still resolve.Reproduced the bug by running the new test against main's
google-calendar-read.ts: both cases fail; with this change both pass.vitest --config config/vitest.config.ts src/main/google: 9 files, 58 tests pass on the rebased commit.Touched files pass oxfmt, oxlint, anti-slop oxlint, native code-quality oxlint, ast-grep, and the changed-code quality gate.
Platforms: macOS (unit level). The code is platform-neutral async network I/O.
Performance
None on any hot path: this only runs when a user runs a calendar command (
orca calendar list/get/create/update, free-time) and is never polled; the trigger checker usesgoogle-calendar-changes.ts, not this code. No new sync I/O or subprocesses, and no renderer/store changes. Benchmark with stubbed HTTP, 250 entries per page:All waits are async, so nothing blocks the main process; the extra cost is only the network round trips needed for a correct answer.
Risk
Level: Low
The riskiest part is extra requests for users with more than 250 calendars; each request keeps the existing per-request timeout. A name that used to resolve silently to the wrong calendar now returns an "ambiguous" error asking for the calendar id. Past the 20-page cap, listing and name lookup fail explicitly instead of returning partial results. Id and
primarylookups are unchanged. No saved-data or wire-format change; back out with a plain revert.Review
Fix by @Afloat16. Maintainer pass: squashed onto current main as a single commit with authorship preserved; diff is identical to the reviewed change.
Agent skill upstream boundary
Notes
Security: no new endpoints; it calls the same googleapis
calendarListURL with apageTokenparameter set viaURLSearchParams. Cross-platform: pure TS, no paths or shell. Remote SSH and mobile go through the existing RPC entry points; response shape is unchanged, so older clients are unaffected.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)