Skip to content

usage-import: timezone-naive --since/--until crashes (offset-naive vs offset-aware datetime comparison) #12

Description

@blue-az

Repro

./operator usage-import --harness claude --since 2026-07-17T00:00:00 --dry-run
File ".../operator", line 2806, in usage_import_cmd
    if since_dt <= s["start_time"] <= until_dt:
TypeError: can't compare offset-naive and offset-aware datetimes

Session start_time values parsed from harness logs are timezone-aware; a --since/--until given without an offset parses naive and the comparison raises before any filtering happens.

Workaround

Pass an explicit offset: --since 2026-07-17T00:00:00-07:00 works.

Suggested fix

Normalize user-supplied boundaries after parsing: if tzinfo is None, assume the local timezone (.astimezone()), matching how a user reads their own clock. One-liner at the parse site feeding line 2806.

Found 2026-07-17 while re-feeding the usage ledger from Claude session logs (first import after the ledger went stale 2026-07-02).

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions