Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review round 4 (codex): reject extended-year timestamps outside PG range
Adam Eivy7c6b0ebbc655
diff --git a/server/services/creativeDirector/projectsLogic.js b/server/services/creativeDirector/projectsLogic.jsindex f11d5a2ce8..69e764d4b7 100644--- a/server/services/creativeDirector/projectsLogic.js+++ b/server/services/creativeDirector/projectsLogic.js@@ -75,11 +75,20 @@ export function mirrorStatus(status) {* value PG always accepts. The raw original is still preserved verbatim in the* JSONB `data` (callers stringify the full record separately), so this only* affects the queryable mirror column.+ *+ * Extended-year guard: `toISOString()` emits a plain 4-digit year (`YYYY-…`)+ * only for years 0000–9999, and a SIGNED expanded form (`±YYYYYY-…`) otherwise.+ * A normalized year outside 4-digit range (e.g. `-100000-01-01`, which+ * `Date.parse` accepts) is outside Postgres TIMESTAMPTZ range and would still+ * throw on bind — so we require the leading 4-digit form and fall back otherwise.*/export function mirrorTimestamp(value, fallback) {if (typeof value === 'string') {const ms = Date.parse(value);- if (!Number.isNaN(ms)) return new Date(ms).toISOString();+ if (!Number.isNaN(ms)) {+ const iso = new Date(ms).toISOString();+ if (/^\d{4}-/.test(iso)) return iso;+ }}return fallback;}diff --git a/server/services/creativeDirector/projectsLogic.test.js b/server/services/creativeDirector/projectsLogic.test.jsindex c16a4b1ddc..50f0049505 100644--- a/server/services/creativeDirector/projectsLogic.test.js+++ b/server/services/creativeDirector/projectsLogic.test.js@@ -131,6 +131,10 @@ describe('mirrorStatus / mirrorTimestamp (typed-column safety)', () => {expect(mirrorTimestamp('not-a-date', 'fb')).toBe('fb');expect(mirrorTimestamp(12345, 'fb')).toBe('fb');expect(mirrorTimestamp(null, 'fb')).toBe('fb');+ // Extended-year ISO that Date.parse accepts but is outside Postgres+ // TIMESTAMPTZ range → must fall back, not bind a ±YYYYYY string that throws.+ expect(mirrorTimestamp('-100000-01-01T00:00:00.000Z', 'fb')).toBe('fb');+ expect(mirrorTimestamp('+275760-09-13T00:00:00.000Z', 'fb')).toBe('fb');});});