Skip to content

Normalize YAML timestamp values for gojq - #77

Merged
JFryy merged 1 commit into
JFryy:mainfrom
jihtsan:codex/76-normalize-yaml-timestamp-values
Nov 2, 2026
Merged

JFryy merged 1 commit into
JFryy:mainfrom
jihtsan:codex/76-normalize-yaml-timestamp-values

Conversation

@jihtsan

@jihtsan jihtsan commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Description

Closes #76. YAML timestamp values currently remain time.Time, which gojq cannot encode and can panic on, even though timestamp keys already have a stable string representation. Normalize values with the same existing timestampString helper so top-level, nested, sequence and multi-document values are safe for gojq and agree with keys.

Changes

  • Fixed the timestamp-value normalization bug without changing the existing timestamp-key format.
  • Added regressions for dates, UTC, offsets/fractions, recursive shapes, multi-document inputs, gojq encoding and key/value parity; quoted strings and null remain controls.

Testing

On macOS with Go 1.25.12:

  • go test -count=1 ./..., go vet ./..., and build passed.
  • make test passed, including the shell integration harness (347 passed, 171 skipped by that harness).
  • go test -race -count=1 ./codec/... passed.
  • Built CLI: printf 'a: 2024-01-01\n' | qq -iyaml tojson completes with the date string instead of panicking.

Additional Notes

Full go test -race -count=1 ./... fails in the pre-existing CLI tests' concurrent stdout/Version handling. Running go test -race -count=1 ./cli in a separate, unmodified worktree at base 0ca9d3c3a9a1206259c39b99e927df81a29c22e2 reproduces that race. It is not reported as passing or changed here. Linux/Windows were not run locally. Timestamp lexical spellings are normalized using the existing formatter, not preserved verbatim.

@JFryy JFryy left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for submitting this! Looks good

@JFryy
JFryy merged commit b18dc94 into JFryy:main Nov 2, 2026
1 check passed
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.

YAML timestamps decode to time.Time: panic as values, Go debug string as keys

2 participants