fix(timeutil): accept RFC3339 timestamps in --since/--until#25
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
An ai-sre agent session (
分析故障 6a1935eb) failed with: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 ofincident listoutput and fed RFC3339 values straight back intochange list --since/--until. Buttimeutil.Parseonly 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
Parsenow triesRFC3339Nano/RFC3339(honoring the embedded offset orZ) before the local-zone layouts, and also accepts theT-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
+08:00offset,Z, fractional-secondRFC3339Nano, and bare-Tno-tz; full suite green.localhost:11480):change list --since 2026-05-29T00:00:00+08:00 --until 2026-05-29T14:00:00+08:00now exits 0;incident list --since 2026-05-29T00:00:00Zreturns real rows; garbage input still rejected (now with RFC3339 listed in the hint).