Skip to content

fix(calendar): expand offset-only recurring events in the calendar's zone - #1310

Closed
saariuslystoned wants to merge 5 commits into
openclaw:mainfrom
saariuslystoned:fix/calendar-recurring-calendar-timezone
Closed

saariuslystoned wants to merge 5 commits into
openclaw:mainfrom
saariuslystoned:fix/calendar-recurring-calendar-timezone

Conversation

@saariuslystoned

@saariuslystoned saariuslystoned commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

What problem this solves

For a recurring event, Google needs start.timeZone and end.timeZone as IANA names. The Events reference says the field "is required and specifies the time zone in which the recurrence is expanded". docs/dates.md tells agents to pass an explicit offset, and calendar create --from/--to takes RFC3339 only. When that offset is the only zone information, extractTimezone picks the zone:

calendar focus-time --rrule builds its times the same way and has both problems.

Change

When a calendar create or calendar focus-time event has --rrule and a time carries only an offset, gog checks the target calendar's time zone. If that zone has the same offset at the given instant, gog sends the calendar's IANA name. The dateTime is unchanged, so the first occurrence keeps the same instant and later occurrences keep its local time. This only uses a zone the calendar already has. It doesn't guess between regions that share an offset, which was the concern in #492.

Unchanged:

  • explicit --timezone, --start-timezone and --end-timezone
  • UTC times (Z, +00:00)
  • all-day dates
  • single events
  • offsets that don't match the calendar's zone, which keep Etc/GMT±N
  • a failed calendar lookup, which falls back to the previous behavior

If an offset still has no zone after the check (for example +05:30 on a UTC calendar), calendar create returns a usage error that names --timezone before inserting anything, instead of sending a request Google rejects. focus-time has no timezone flag, so it keeps sending the request as before.

writeEvent already called Calendars.Get after every create to format its output. The lookup is now cached on the mutation context, so a recurring create still makes one calendar read. --dry-run still makes no API calls. When a recurring event's time carries only an offset, the dry-run request now adds a recurring_timezone_lookup entry for start and end. Each entry gives the offset, the rule ("use the calendar's time zone if it has this offset at dateTime") and the fallback: the Etc/GMT zone, the usage error asking for --timezone, or for focus-time "no time zone is sent". The preview no longer presents the fallback zone as final. Explicit timezone flags and UTC times need no lookup and get no entry.

Evidence

  • internal/cmd/calendar_recurring_timezone_test.go drives CalendarCreateCmd and CalendarFocusTimeCmd against an httptest Calendar server and checks the inserted event:

    • -08:00 with a America/Los_Angeles calendar
    • +05:30 with Asia/Kolkata
    • +05:30 with a UTC calendar, which must return the usage error with no insert
    • Z with a Europe/London calendar, which keeps UTC
    • --start-timezone, which keeps the explicit zone
    • recurring focus time

    Five fail on main (e8428c3) and pass with this change. TestCalendarCreateCmd_DryRunDeclaresRecurringTimezoneLookup and TestCalendarFocusTimeCmd_DryRunDeclaresRecurringTimezoneLookup cover the dry-run entry, including no entry with --timezone. A sixth test pins single events to Etc/GMT+8, and the existing TestCalendarCreateCmd_RecurringOffsetTimezoneFallback (+02:00 on a UTC calendar stays Etc/GMT-2) still passes.

  • A built bin/gog from main and from this branch was run against a local Calendar stand-in through GOG_GOOGLE_API_BASE_URL, with an empty GOG_HOME and the file keyring. The stand-in is not Google. It serves calendars/primary with a chosen zone, and it answers a recurring insert that has no start.timeZone with the 400 from Bug: Missing time zone definition for start time when creating recurring events #347:

    -08:00, calendar America/Los_Angeles
      main:   POST .../events start tz=Etc/GMT+8 end tz=Etc/GMT+8            exit 0
      branch: POST .../events start tz=America/Los_Angeles end tz=America/Los_Angeles   exit 0
    +05:30, calendar Asia/Kolkata
      main:   POST .../events start tz=None -> 400 Missing time zone definition   exit 1
      branch: POST .../events start tz=Asia/Kolkata end tz=Asia/Kolkata  exit 0
    +05:30, calendar UTC
      main:   POST .../events start tz=None -> 400                       exit 1
      branch: usage error naming --timezone, no POST                     exit 2
    
  • Live Google Calendar runs on throwaway secondary calendars in a Workspace account, deleted afterwards. main is gog built from e8428c3; the branch build contains this change. Values are as Google returned them:

    calendar timeZone America/Los_Angeles
    $ gog calendar create CAL --from 2026-11-10T09:00:00-08:00 --to 2026-11-10T09:30:00-08:00 --rrule 'RRULE:FREQ=WEEKLY;COUNT=20'
    main:   stored start timeZone Etc/GMT+8
    branch: stored start timeZone America/Los_Angeles
    $ gog calendar events CAL --from 2027-03-15T00:00:00Z --to 2027-03-23T00:00:00Z
    main:   2027-03-16T10:00:00-07:00  Etc/GMT+8              <- one hour late after DST starts
    branch: 2027-03-16T09:00:00-07:00  America/Los_Angeles
    
    calendar timeZone Asia/Kolkata
    $ gog calendar create CAL --from 2026-11-10T09:00:00+05:30 --to 2026-11-10T09:30:00+05:30 --rrule 'RRULE:FREQ=DAILY;COUNT=3'
    main:   exit=1  Google API error (400 required): Missing time zone definition for start time.
    branch: exit=0  stored start timeZone Asia/Kolkata
    
    calendar timeZone America/Los_Angeles, same +05:30 series (offset matches no zone the calendar uses)
    main:   exit=1  Google API error (400 required): Missing time zone definition for start time.
    branch: exit=2  recurring events need an IANA time zone: --from offset +05:30 has no fixed-offset zone and does not match the calendar's time zone; pass --timezone with an IANA zone name
    
  • When --start-timezone or --end-timezone already sets one endpoint's zone, the unresolved-offset error and the dry-run plan now name the other endpoint's own flag. Suggesting --timezone there failed, because it cannot be combined with them. TestCalendarCreateCmd_RecurringUnresolvedEndSuggestsGranularFlag covers a UTC calendar with --start-timezone Asia/Kolkata and +05:30 times. It fails on the previous head 42d6607 (the error says pass --timezone) and passes on 0690277 (the error says pass --end-timezone).

  • CI on 0690277:

    • fmt, lint, deadcode, docs, agent-skills and node checks pass locally (macOS arm64, go1.27.3).
    • go test -count=1 ./... ran on a second macOS arm64 machine. In that run, internal/secrets TestRekey_Permissions failed once and every other package passed. The failure did not reproduce: on 0690277 the test then passed on that machine, three times alone and once with its whole package, and it passed locally at both 0690277 and e8428c3. This change does not touch internal/secrets.

Boundary: the live runs above cover calendar create. calendar focus-time uses the same helper and is covered by the tests only.

🤖 Generated with Claude Code

…zone

Google expands a recurring event in start.timeZone. When --from/--to
carry only an offset, create and focus-time sent a fixed Etc/GMT zone,
so the series kept that offset across daylight saving changes, or no
zone at all for half-hour offsets such as +05:30, which Google rejects
with "Missing time zone definition for start time".

Use the calendar's IANA zone when it has the same offset at that
instant. Explicit timezone flags, UTC, all-day dates and single events
are unchanged. An offset that still has no zone in calendar create is
a usage error naming --timezone. The calendar lookup is cached on the
mutation context, so the command still reads the calendar once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@clawsweeper

clawsweeper Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

saariuslystoned and others added 2 commits November 8, 2026 07:47
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 8, 2026
@clawsweeper

clawsweeper Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR uses a matching calendar timezone for offset-only recurring events and rejects unresolved fractional offsets during creation.

Example: Create a weekly 09:00 event on an America/Los_Angeles calendar using 2026-11-10T09:00:00-08:00.

  • Before: The series uses Etc/GMT+8 and occurs at 10:00 local time on 2027-03-16.
  • After: The series uses America/Los_Angeles and occurs at 09:00 local time on 2027-03-16.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The previous finding is repaired and no new discrete defect was established; partial live coverage and the unresolved recurrence-default decision limit readiness.
Proof confidence 🦐 gold shrimp (3/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Needs a maintainer decision · Fix scope: Complete
User problem: Offset-only recurring events can fail for fractional offsets or follow fixed-offset time when users expect the calendar's local time.
Reason: The validation improvement has clear value, but automatic regional recurrence changes designed behavior already controllable through explicit flags and lacks owner approval.

Merge readiness

⛔ Blocked before merge - 1 item remains

This PR addresses a current recurring-event failure; the previous diagnostic finding is fixed, but changing the deliberate fixed-offset default still needs a calendar owner's decision.

Priority: P2
Reviewed head: 0690277fc20af640d0e17cfe8f1669d0f7f8bce9
Owner decision: Required. See Decision needed.

Decision needed

  • Question: Should offset-only recurring creates automatically adopt a matching calendar region, replacing the intentional fixed-offset default?
  • Recommendation: Keep the fixed-offset default: Ask the contributor to narrow this PR to actionable errors for unresolved recurring offsets, using the existing explicit timezone flags to select regional recurrence.
  • Why: Matching an offset establishes the first instant, not the caller's intended DST policy; prior history deliberately avoided regional inference, and no maintainer has approved this replacement.

Before merge

  • Add real behavior proof - The body supplies useful live Google Calendar CLI results for create, including DST expansion, Kolkata acceptance, and unmatched-offset rejection; focus-time remains test-only, and the previously requested fresh-install versus v0.48.0-upgrade evidence is absent, so the contributor should supply scoped terminal output or logs with account identifiers, IPs, keys, tokens, and non-public endpoints redacted. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.

Findings

None.

Tests

  • Missing end-to-end proof: Add redacted shipped-CLI evidence for recurring focus-time and fresh versus v0.48.0-upgrade behavior preserving existing auth, configuration, and explicit timezone choices; the body reports base-failing regression tests, which this review did not execute.
Agent review details

How this fits together

Calendar CLI commands build event payloads from datetime flags, resolve calendar metadata through the authenticated Calendar service, and insert events through Google's API.

flowchart TD
A[Calendar CLI flags] --> B[Event planning]
B --> C[Offline dry run]
B --> D[Recurring timezone resolution]
E[Calendar timezone metadata] --> D
D --> F[Calendar event insert]
F --> G[Formatted event output]
Loading

Technical review

Best possible solution:

Preserve the explicit timezone contract and add actionable validation for unresolved recurring offsets unless the calendar owner approves automatic regional expansion.

Do we have a high-confidence way to reproduce the issue?

Current-main source omits timezone metadata for fractional offsets, and the contributor's live CLI output demonstrates Google's rejection; no target code or tests were run during this read-only review.

Is this the best way to solve the issue?

The implementation shares resolution between create and focus-time and preserves explicit flags, but automatically selecting a region exceeds the narrow validation repair and changes an intentional default.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against e8428c36dd31.

Provenance checked

  • Offset-only timezone selection changes intended behavior with a stated reason (df3e97f: Avoid ambiguous regional guesses from numeric offsets; the contributor explains why matching the calendar's own zone is preferable for local recurrence.)
  • Create planning and offline dry runs keeps the original intent (c624164: Extract request planning from command execution; this PR keeps dry runs offline and describes the deferred calendar lookup.)
  • Shared mutation execution and output timezone lookup keeps the original intent (aaafcca: Share mutation helpers; this PR retains that owner and caches its existing calendar lookup per command.)
  • Focus-time dry-run behavior keeps the original intent (3371e3f: Provide agent-facing dry-run plans; the additional lookup description preserves the no-API-call boundary.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Repository review policy applied: Read the complete root AGENTS.md; no ancestor AGENTS.md files exist under internal or docs, and neither maintainer notes nor a pr-simplify skill is present. The patch includes an Unreleased changelog entry with the PR reference and contributor credit. (AGENTS.md:1, 0690277fc20a)
  • Current main retains the reported boundary: extractTimezone returns fixed Etc/GMT zones for whole-hour offsets and no timezone for fractional offsets; it does not consult the target calendar. (internal/cmd/calendar_build.go:85, e8428c36dd31)
  • Fixed-offset behavior was intentional: Commit df3e97f removed regional guessing because multiple regions share an offset. The maintainer's discussion at calendar: avoid ambiguous timezone inference from offsets #492 credits that manually landed change; automatic calendar-zone selection is a new policy choice. (internal/cmd/calendar_build.go:96, df3e97faed3f)
  • Explicit timezone capability already exists: feat(calendar): add --timezone flag to event create #844 added the explicit --timezone choice and was landed after maintainer review; it supplies the regional recurrence behavior when callers specify their intent. (internal/cmd/calendar_build.go:61, b35481eefd60)
  • Previous finding resolved: The current head selects --end-timezone when --start-timezone is already supplied, updates the dry-run guidance, and adds a command-path regression test for that case. (internal/cmd/calendar_build.go:127, 0690277fc20a)
  • Contributor live evidence inspected: The complete current body supplies shipped-CLI Google Calendar output for regional DST expansion, successful Kolkata creation, and rejection of an unmatched fractional offset; it expressly limits live coverage to create. Captured body sourceRevision: 1db951a37701dd2103924a39d149ff8185844a5e026ec48d34d1b8b890fafe4d.

Likely related people:

  • Malo Bourgon: Raw commit b35481e adds internal/cmd/calendar_build.go:60 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: b35481eefd60; files: internal/cmd/calendar_build.go)

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: The change concerns recurring scheduling and fractional-offset creation failures, with existing explicit timezone flags providing a workaround.
  • merge-risk: 🚨 compatibility: The same offset-only command can create a regional DST-following series after upgrade instead of a fixed-offset series.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Complete the scoped focus-time and upgrade evidence identified in the proof assessment.
  • Resolve the calendar owner's choice between fixed-offset and automatic regional recurrence.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (3 earlier review cycles)
  • reviewed 2026-11-08T13:03:19.540Z sha d2d46d4 :: needs real behavior proof before merge. :: [P2] Declare calendar-dependent timezone resolution in dry-run plans
  • reviewed 2026-11-08T13:28:14.120Z sha 42d6607 :: needs real behavior proof before merge. :: none
  • reviewed 2026-11-09T02:40:53.934Z sha 42d6607 :: needs real behavior proof before merge. :: [P3] Recommend a timezone flag compatible with granular overrides

Reviewed November 9, 2026, 1:34 AM ET / 06:34 UTC (Revision 4).

A recurring create or focus-time with offset-only times sends the
calendar's zone when it matches, but --dry-run stays offline and showed
the fallback Etc/GMT zone as if it were final. Add a
recurring_timezone_lookup entry with the offset, the rule and the
fallback to both dry-run plans. The create plan now carries the explicit
timezone flags it resolved, and Run reuses them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@saariuslystoned

Copy link
Copy Markdown
Contributor Author

Thanks for the review.

  • Dry-run divergence (P2): pushed 42d6607. Dry runs still make no API calls. For offset-only recurring times in calendar create and calendar focus-time, they now include a recurring_timezone_lookup entry with the offset, the rule and the fallback, so the preview no longer shows Etc/GMT+8 as final. Two tests cover it, and make ci passes locally.
  • Default: that's your decision. If you'd rather keep fixed offsets, the narrower repair the review describes is a subset of this PR. It keeps only the usage error for offsets that have no Etc/GMT zone, which is the Missing time zone definition case from Recurring Events Fail with "Missing time zone definition" Error #216 and Bug: Missing time zone definition for start time when creating recurring events #347, and drops the calendar-zone match. I can cut the PR down to that.
  • Live proof needs a real Google Calendar and wasn't run from here. The check that would show it is in the body's boundary paragraph.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 8, 2026
@saariuslystoned

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 9, 2026
…y set

--timezone cannot be combined with --start-timezone or --end-timezone. When one endpoint already has its own zone, the unresolved-offset error and the dry-run plan now name the other endpoint's flag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@saariuslystoned

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 9, 2026
@saariuslystoned

Copy link
Copy Markdown
Contributor Author

Closing to keep the existing fixed-offset recurrence default. A narrower error-reporting change can come separately if it's wanted.

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

Labels

merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P2 Normal priority bug or improvement with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant