Skip to content

fix(google-calendar): encode calendar/event ids before URL paths - #13657

Open
Da7em-T wants to merge 2 commits into
BasedHardware:mainfrom
Da7em-T:fix/gcal-path-segment-encoding
Open

Da7em-T wants to merge 2 commits into
BasedHardware:mainfrom
Da7em-T:fix/gcal-path-segment-encoding

Conversation

@Da7em-T

@Da7em-T Da7em-T commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

calendar_id and event_id come from the tool request body and were interpolated raw into Google Calendar API paths at every tool handler (list/create/get/update/delete — 7 sites).

  • Legitimate Google calendar ids contain # — e.g. en.usa#[email protected]. A literal # turns the rest of the URL into a fragment, truncating the request path to /calendars/en.usa — holiday/shared calendars silently hit the wrong endpoint.
  • / or .. in either id could rewrite the request path under the API host (e.g. event_id=x/../../acl/owner).

path_segment() percent-encodes each id (quote(..., safe="")) at each interpolation site.

Verification

plugins/omi-google-calendar-app/test_path_encoding.py (new, hermetic, registered as gcal-path-segment-encoding-tests in .github/checks-manifest.yaml) drives the real tool handlers with a recorded requests stub:

  • tool_list_events with calendar_id=en.usa#[email protected]: old code produces a URL containing a literal # (test fails — request path truncated); fixed code sends en.usa%23holiday%40...
  • tool_delete_event with event_id=x/../../acl/owner: fixed code keeps one /events/ segment and no literal .. path parts
  • tool_get_event with primary/evt_1: unchanged /calendars/primary/events/evt_1

3/3 pass on the fix; the # truncation test fails on the original code.

Failure-Class: none

Review in cubic

Tool-body calendar_id/event_id were interpolated raw into Google
Calendar API paths at every tool handler. Legitimate calendar ids
contain '#' (e.g. en.usa#[email protected]), which
truncates the request URL and breaks those calendars; '/' or '..' in
either id could also rewrite the request path under the API host.

path_segment() percent-encodes each id (quote with safe="") at the seven
interpolation sites covering list/create/get/update/delete.

Verified: test_path_encoding.py drives the real tool handlers with a
recorded requests stub. On old code the holiday-calendar id produces a
URL containing a literal '#' (assertion fails); with the fix ids arrive
percent-encoded and plain ids pass through unchanged. 3/3 pass.

Failure-Class: none

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 3 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread plugins/omi-google-calendar-app/main.py Resolved
… tests

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@Git-on-my-level Git-on-my-level added python positive-signal Automation verified a genuine fix/quality contribution security-review Touches auth, provider routing, secrets, or security-sensitive surfaces labels Sep 12, 2026
@Git-on-my-level

Copy link
Copy Markdown
Member

Thanks @Da7em-T — this is a solid, well-scoped fix, and the follow-ups from the earlier review round (dot-segment rejection, the requests stub in the hermetic loader, create/update coverage) are all addressed in b05f811.

Verified on this head:

  • plugins/omi-google-calendar-app/main.py — path_segment() (line 41) rejects ./.. and percent-encodes everything else via quote(value, safe=""), and all eight interpolation sites now go through it: list (519), create (634), get (686), update preflight + PATCH (761, 806), delete preflight + DELETE (842, 845). The fail-closed path holds: a .. event id raises inside the handler's try/except and returns a clean "invalid calendar or event id" error with no outbound API call. Plain ids (primary, evt_1) pass through byte-identical, and #-bearing ids like en.usa#[email protected] now reach the API as en.usa%23holiday%40... instead of truncating at the fragment.
  • plugins/omi-google-calendar-app/test_path_encoding.py — ran it against the head files: 6/6 pass. The sys.modules stub set (fastapi, fastapi.responses, dotenv, db, models, requests) makes it genuinely hermetic, and the URL-recording fake covers # truncation, traversal, fail-closed, and pass-through across four different handlers — good regression net for path_segment.
  • .github/checks-manifest.yaml — gcal-path-segment-encoding-tests is registered for both local and ci lanes with triggers scoped to the plugin path and the manifest itself; the reason string matches the actual bug.

On the red checks: none of them come from this PR. Dart Analyze & Tests fails on compile errors in app/test/providers/deletion_consistency_test.dart and app/test/widgets/chat_content_blocks_test.dart — the same errors reproduce on unrelated PR branches in the same window, so this is a pre-existing main breakage. Both Desktop Swift jobs failed on wall-clock budget overruns (2468s against the 1800s budget), not on test failures. This PR touches no Swift or Dart.

Since this changes URL/input validation on an authenticated Google Calendar API surface, it should get maintainer sign-off before merge — the code looks right to me, but that surface warrants human eyes. Leaving a positive signal for human maintainer review.


This review was written by AI on behalf of David

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Google Calendar id path-encoding fix (# truncation / path traversal), well-tested. CI: Dart Analyze & Tests fails (stale base, unrelated) and Desktop Swift tests also red on this frozen base despite zero Swift changes in diff — approved, not merged, needs rebase for clean CI.

@Git-on-my-level

Copy link
Copy Markdown
Member

Follow-up verification on this head (b05f811), adding execution evidence on top of the approval above:

  • plugins/omi-google-calendar-app/main.py — path_segment() (quote with safe="", rejecting "."/"..") is applied at all seven interpolation sites: tool_list_events, tool_create_event, tool_get_event, and the GET/PATCH/DELETE calls in tool_update_event and tool_delete_event. The ValueError branch for "."/".." lands in each handler's existing except and returns a clean error response — it fails closed rather than mangling the URL.
  • plugins/omi-google-calendar-app/test_path_encoding.py — ran it locally against this head: 6/6 pass. Also ran it against pre-PR main.py: test_calendar_id_with_hash_is_encoded_not_truncating fails with the URL .../calendars/en.usa#[email protected]/events, i.e. the literal # really does truncate the request path — so the regression test is demonstrably non-vacuous. The harness stubs fastapi/db/requests and needs no network or credentials.
  • .github/checks-manifest.yaml — the new gcal-path-segment-encoding-tests entry wires that test into both local and ci lanes with trigger paths that match the plugin directory; the command path matches the file location.

On the red CI lanes: Dart Analyze & Tests fails with a compile-time type error in app/test/widgets/chat_content_blocks_test.dart (ActionItemsFetcher mismatch) and the Desktop Swift lanes fail on the test-step time budget — this diff touches no Dart or Swift files, and both failures reproduce from the base, so a rebase should clear them.

Thanks @Da7em-T — the # truncation vs path-injection distinction is exactly right, and rejecting dot segments outright instead of encoding them is the correct call.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Path-segment encoding fix for Google Calendar tool handlers; real calendar ids contain # which truncated requests, and unencoded ids allowed path rewriting; well tested.

@Git-on-my-level

Copy link
Copy Markdown
Member

Status update for @Da7em-T: the base breakage that kept this branch's Dart lane red has been fixed upstream. Dart Analyze & Tests passes on current-day PRs against main (it was failing on compile errors in app/test/widgets/chat_content_blocks_test.dart and app/test/providers/deletion_consistency_test.dart when this branch froze, which is why it was red here). A rebase onto main should now clear the last red check — after that this should be ready to merge once a maintainer gives the final go.

Nothing new on re-verification of b05f811: all path_segment() sites in plugins/omi-google-calendar-app/main.py (list, create, get, update GET+PATCH, delete GET+DELETE) are covered, the only remaining raw {calendar_id}/{event_id} interpolations are display/log strings that never build a URL, and plugins/omi-google-calendar-app/test_path_encoding.py still passes 6/6 hermetically (no network or credentials needed).


by AI on behalf of David

@aryanorastar

Copy link
Copy Markdown
Collaborator

Keeping this open on b05f81146b2f.

DIRTY + Dart Analyze red; gcal path-id encode + tests; kodjima APPROVE ≠ merge.

kodjima APPROVE is the size gate, not maintainer merge.

I am not approving or merging this SHA.

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Real bug: unencoded calendar/event ids in Google Calendar API paths truncate on legitimate '#'-containing calendar ids and allow path rewriting via '/'/'..'. Scoped percent-encoding fix with hermetic tests. Only red check is the same pre-existing unrelated Dart compile error.

@aryanorastar

Copy link
Copy Markdown
Collaborator

Google Calendar on main still builds event paths with raw ids. This head quotes them with safe="" and rejects . and ... b05f81146b2f conflicts, so rebase it. This stays open and unapproved.

— Astar, on behalf of @aryanorastar

@aryanorastar

Copy link
Copy Markdown
Collaborator

Keeping this open. Not approving b05f81146b2f. origin/main still interpolates f"/calendars/{calendar_id}/events" raw (main.py ~559). CONFLICTING/DIRTY, CI FAILURE. Do not approve.

— Astar, on behalf of @aryanorastar

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

positive-signal Automation verified a genuine fix/quality contribution python security-review Touches auth, provider routing, secrets, or security-sensitive surfaces

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants