Skip to content

fix(timeutil): accept RFC3339 timestamps in --since/--until#25

Merged
ysyneu merged 1 commit into
mainfrom
fix/timeutil-rfc3339
May 31, 2026
Merged

fix(timeutil): accept RFC3339 timestamps in --since/--until#25
ysyneu merged 1 commit into
mainfrom
fix/timeutil-rfc3339

Conversation

@ysyneu
Copy link
Copy Markdown
Contributor

@ysyneu ysyneu commented May 31, 2026

Problem

An ai-sre agent session (分析故障 6a1935eb) failed with:

unable to parse time "2026-05-29T00:00:00+08:00"

Root cause — an output/input asymmetry. The flashduty SDK renders timestamps as RFC3339 (e.g. incident start_time: "2026-05-24T15:25:58+08:00"). The agent read that out of incident list output and fed RFC3339 values straight back into change list --since/--until. But timeutil.Parse only accepted duration / 2006-01-02 / 2006-01-02 15:04:05 / unix — not the RFC3339 we ourselves emit. The agent had to burn a self-correction turn reformatting to space-separated datetime.

Fix

Parse now tries RFC3339Nano/RFC3339 (honoring the embedded offset or Z) before the local-zone layouts, and also accepts the T-separated datetime without a timezone. Output is unchanged — this only widens accepted input to include the exact shape we already emit, closing the round-trip.

Verification

  • Unit tests cover +08:00 offset, Z, fractional-second RFC3339Nano, and bare-T no-tz; full suite green.
  • Replayed the original failing command against dev (localhost:11480): change list --since 2026-05-29T00:00:00+08:00 --until 2026-05-29T14:00:00+08:00 now exits 0; incident list --since 2026-05-29T00:00:00Z returns real rows; garbage input still rejected (now with RFC3339 listed in the hint).

The flashduty SDK renders timestamps as RFC3339 (e.g.
"2026-05-29T00:00:00+08:00"), so the ai-sre agent naturally copies those
values straight out of one command's output back into --since/--until of
the next. timeutil.Parse only understood duration / "2006-01-02" /
"2006-01-02 15:04:05" / unix, so it failed with
`unable to parse time "2026-05-29T00:00:00+08:00"`, costing the agent a
wasted self-correction turn.

Parse now tries RFC3339/RFC3339Nano (honoring the embedded offset or "Z")
before the local-zone layouts, and also accepts the "T"-separated datetime
without a timezone. Output is unchanged; this only widens accepted input
to include the exact shape we already emit.
@ysyneu ysyneu merged commit c9000d5 into main May 31, 2026
12 checks passed
@ysyneu ysyneu deleted the fix/timeutil-rfc3339 branch May 31, 2026 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant