Commit 52b37a7
committed
fix: render unset timestamps as null in --json output
go-flashduty's Timestamp.MarshalJSON emits a quoted RFC3339 string for a
set value but the bare integer 0 for the unset sentinel, so one field
switches JSON type depending on record state: an active alert's end_time
is the number 0 while a recovered alert's is a string. jq arithmetic over
mixed-state output fails with "string and number cannot be subtracted".
Add output.NullUnsetInstants, a reflection-based transform applied at the
JSON marshaling boundary (JSONPrinter.Print and marshalStructured), that
replaces every unset SDK timestamp with nil so it renders as null. Set
values keep their concrete type and custom MarshalJSON, non-timestamp
zero integers are untouched, and struct field order is preserved
(verified byte-identical when no unset instant is present). TOON and
table output are unchanged: they render the sentinel through String(),
already always a string.
The generated help note and the skill card prose that documented the old
"unset stays the bare integer 0" contract are updated to match.1 parent ae99505 commit 52b37a7
42 files changed
Lines changed: 1049 additions & 660 deletions
File tree
- internal
- cli
- cmd/cligen
- output
- skills/flashduty
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
258 | 258 | | |
259 | 259 | | |
260 | 260 | | |
261 | | - | |
262 | | - | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
263 | 264 | | |
264 | 265 | | |
265 | 266 | | |
266 | 267 | | |
267 | | - | |
| 268 | + | |
268 | 269 | | |
269 | 270 | | |
270 | 271 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments