Skip to content

bug(calendar): freebusy sends an inverted RFC3339 window to the API instead of rejecting it #1328

Closed

Description

@privatenumber

Summary

#1280 made calendar commands reject an empty or inverted window as a usage error. calendar freebusy still sends an inverted window to the API when both bounds are RFC3339 timestamps, so the command fails with the Google API error instead.

Current (v0.48.0, also main at e8428c3)

gog calendar freebusy --from 2027-01-02T00:00:00Z --to 2027-01-01T00:00:00Z
# Google API error (400 timeRangeEmpty): The specified time range is empty.   (exit 1)

gog calendar freebusy --from 2027-01-02 --to 2027-01-01
# --from (2027-01-02T00:00:00Z) must be before --to (2027-01-02T00:00:00Z)   (exit 2; a date-only --to includes that day)

resolveFreeBusyRange returns two RFC3339 bounds unchanged and only sends other forms through ResolveTimeRange, which has the new check (calendar_freebusy.go#L73-L87).

Expected

An inverted or empty window is a usage error (exit 2) before the request, whatever form the bounds take, as for the other calendar commands.

One possible approach, not a requirement: keep the passthrough, which preserves the exact instants, but compare the two parsed instants before returning them.

Environment

gog built from main at e8428c3. Reproduced against a local fake of the Calendar API through GOG_GOOGLE_API_BASE_URL; the fake returns the API's timeRangeEmpty error for an empty range.

Activity

  1. added
    clawsweeper:intake:bugPreliminary submission classification; full source review pending.
    P2Normal priority bug or improvement with limited blast radius.
    clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.
    clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.
    clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.
    impact:ux-frictionUser-facing flow adds avoidable confusion or support burden without fully blocking progress.
    issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.
    no-staleExempts this issue from stale automation.
    and removed
    clawsweeper:intake:bugPreliminary submission classification; full source review pending.
    on Nov 11, 2026
  2. clawsweeper commented on Nov 11, 2026

    @clawsweeper
    Contributor

    Codex review: this still needs some work.

    Summary
    This issue establishes a current bug: RFC3339 freebusy bounds bypass range validation on main and v0.48.0.

    Reproducibility: Current source proves that --from 2027-01-02T00:00:00Z and --to 2027-01-01T00:00:00Z reach Freebusy.Query unchecked; the reporter supplies fake-API reproduction, but no runtime reproduction or tests were run during this review.

    Next step
    Establish failing command regressions for equal and reversed RFC3339 bounds, then reject them with exit 2 before the FreeBusy query.

    Review details

    Best possible solution:

    Validate parsed RFC3339 instants locally while preserving valid timestamp strings, fractional precision, and the existing timezone-free path.

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

    Current source proves that --from 2027-01-02T00:00:00Z and --to 2027-01-01T00:00:00Z reach Freebusy.Query unchecked; the reporter supplies fake-API reproduction, but no runtime reproduction or tests were run during this review.

    Is this the best way to solve the issue?

    Comparing parsed instants in the passthrough is a narrow repair; routing all timestamps through the shared resolver would introduce timezone lookups and lose existing fractional-precision behavior.

    AGENTS.md: found and applied where relevant.

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

    Label changes

    Label changes:

    • add P2: Invalid freebusy inputs produce the wrong error class; valid availability queries remain usable.
    • add impact:ux-friction: Equivalent invalid calendar windows receive inconsistent diagnostics and exit codes depending on input format.
    • add issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.
    • add clawsweeper:source-repro: Current issue advisory state selects this label.
    • add clawsweeper:queueable-fix: Current issue advisory state selects this label.
    • add clawsweeper:fix-shape-clear: Current issue advisory state selects this label.

    Label justifications:

    • P2: Invalid freebusy inputs produce the wrong error class; valid availability queries remain usable.
    • impact:ux-friction: Equivalent invalid calendar windows receive inconsistent diagnostics and exit codes depending on input format.
    Evidence reviewed

    Acceptance criteria:

    • Establish failing command-level regressions for reversed, equal, and equal-instant differently offset RFC3339 bounds before implementing the repair.
    • Verify invalid windows return exit 2 without a FreeBusy query and valid offset/fractional windows preserve their exact request strings without timezone requests.
    • go test ./internal/cmd -run 'TestCalendar(FreeBusy|Conflicts|Team)|TestResolveTimeRange'
    • make ci

    What I checked:

    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge; those execution lanes are retired.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

    Reviewed November 11, 2026, 9:15 AM ET / 14:15 UTC.

  3. steipete commented on Nov 14, 2026

    @steipete
    Collaborator

    Fixed in #1336. Equal and inverted RFC3339 free/busy ranges now fail before the API request; valid timestamp strings remain unchanged.

    The regression failed against the previous main and passes with the fix. Full make ci, independent P0–P2 review, and exact-head GitHub CI passed. A built CLI also verified the outgoing request against a synthetic HTTP endpoint.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal priority bug or improvement with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:ux-frictionUser-facing flow adds avoidable confusion or support burden without fully blocking progress.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.no-staleExempts this issue from stale automation.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions