go-sqlite-text-timestamp-to-rfc3339-wire-format
Done. I built a runnable scratch reproduction, verified the fix, and wrote the solution.
~/solution/SOLUTION.md — self-contained write-up: title, root-cause analysis, exact fix, and verification.~/solution/demo/ — working Go module (modernc.org/sqlite, no CGO) with a real table seeded with every timestamp shape, a broken vs. fixed handler, and the raw-body tests.sql.NullString straight to JSON, leaking SQLite's CURRENT_TIMESTAMP layout (2026-08-15 02:13:43) instead of RFC 3339.omitempty on the timestamp tags dropped the keys for pending (NULL) rows, contradicting the documented "" shape."", which is what pending rows are expected to have anyway.formatStoreTimestamp with four branches (empty→"", RFC 3339 passthrough, 2006-01-02 15:04:05→UTC RFC 3339, unknown→unchanged), applied at every construction site, plus dropping omitempty.
"", pending, running, done, failed, weird): 0 RFC 3339 violations on the fixed build, 12 on the broken build.created_at/updated_at as ""; corrupt not-a-timestamp is preserved verbatim.--- PASS: TestRawBodyBroken
--- PASS: TestRawBodyFixed
--- PASS: TestTagTypoPassesDecodedComparisonButFailsRaw
ok demo 0.016s
# Evidence - Problem class: go-sqlite-text-timestamp-to-rfc3339-wire-format - Model: openrouter/deepseek/deepseek-v4.1-flash - Solved: 2026-09-18T13:23:59.122Z - Verification: solution produced by pi in sandbox; see signatures.json
{"description": "Go API serving SQLite TEXT timestamps: a handler that copies a sql.NullString column (CURRENT_TIMESTAMP layout YYYY-MM-DD HH:MM:SS, UTC) straight onto the JSON wire emits a value that time.Parse(time.RFC3339) and new Date() both reject, while sibling endpoints formatted through time.RFC3339. Fix: a formatStoreTimestamp helper that keeps empty as empty, passes an already-RFC3339 value through unchanged, parses the 2006-01-02 15:04:05 layout as UTC and re-formats with time.RFC3339, and returns unrecognised input unchanged rather than dropping it; route every timestamp field through it. Second half: omitempty on those fields makes a pending row drop the keys entirely while the docs example shows them as empty strings \u2014 drop omitempty so the documented shape holds. Prove it by asserting on the RAW response body (a tag typo passes a decoded-struct comparison), then sweep every status filter on a scratch instance built from the change and count RFC3339 violations.", "environment": "linux/amd64", "language": "go", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "go-sqlite-text-timestamp-to-rfc3339-wire-format", "provider": "openrouter", "solved_at": "2026-09-18T13:23:59.122Z", "version": ""}Done. I built a runnable scratch reproduction, verified the fix, and wrote the solution.
~/solution/SOLUTION.md — self-contained write-up: title, root-cause analysis, exact fix, and verification.~/solution/demo/ — working Go module (modernc.org/sqlite, no CGO) with a real table seeded with every timestamp shape, a broken vs. fixed handler, and the raw-body tests.sql.NullString straight to JSON, leaking SQLite's CURRENT_TIMESTAMP layout (2026-08-15 02:13:43) instead of RFC 3339.omitempty on the timestamp tags dropped the keys for pending (NULL) rows, contradicting the documented "" shape."", which is what pending rows are expected to have anyway.formatStoreTimestamp with four branches (empty→"", RFC 3339 passthrough, 2006-01-02 15:04:05→UTC RFC 3339, unknown→unchanged), applied at every construction site, plus dropping omitempty.
"", pending, running, done, failed, weird): 0 RFC 3339 violations on the fixed build, 12 on the broken build.created_at/updated_at as ""; corrupt not-a-timestamp is preserved verbatim.--- PASS: TestRawBodyBroken
--- PASS: TestRawBodyFixed
--- PASS: TestTagTypoPassesDecodedComparisonButFailsRaw
ok demo 0.016s
# Evidence - Problem class: go-sqlite-text-timestamp-to-rfc3339-wire-format - Model: openrouter/deepseek/deepseek-v4.1-flash - Solved: 2026-09-18T13:23:59.122Z - Verification: solution produced by pi in sandbox; see signatures.json
{"description": "Go API serving SQLite TEXT timestamps: a handler that copies a sql.NullString column (CURRENT_TIMESTAMP layout YYYY-MM-DD HH:MM:SS, UTC) straight onto the JSON wire emits a value that time.Parse(time.RFC3339) and new Date() both reject, while sibling endpoints formatted through time.RFC3339. Fix: a formatStoreTimestamp helper that keeps empty as empty, passes an already-RFC3339 value through unchanged, parses the 2006-01-02 15:04:05 layout as UTC and re-formats with time.RFC3339, and returns unrecognised input unchanged rather than dropping it; route every timestamp field through it. Second half: omitempty on those fields makes a pending row drop the keys entirely while the docs example shows them as empty strings \u2014 drop omitempty so the documented shape holds. Prove it by asserting on the RAW response body (a tag typo passes a decoded-struct comparison), then sweep every status filter on a scratch instance built from the change and count RFC3339 violations.", "environment": "linux/amd64", "language": "go", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "go-sqlite-text-timestamp-to-rfc3339-wire-format", "provider": "openrouter", "solved_at": "2026-09-18T13:23:59.122Z", "version": ""}