Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
fix: parse cached date so it does not break zod validation
adilson203bb7c7071f
diff --git a/backend/src/ee/services/insights/insights-fns.ts b/backend/src/ee/services/insights/insights-fns.tsindex f8e5da6af4..bb1733ecf0 100644--- a/backend/src/ee/services/insights/insights-fns.ts+++ b/backend/src/ee/services/insights/insights-fns.ts@@ -19,6 +19,17 @@ export const VALUE_EVENT_TYPES = [export const toUtcDateString = (date: Date) => date.toISOString().slice(0, 10);+export const reviveDates = <T>(rows: T[], ...keys: (keyof T)[]) => {+ for (const row of rows) {+ for (const key of keys) {+ const serialized = row[key] as Date | string | null;+ if (typeof serialized === "string") {+ row[key] = new Date(serialized) as T[typeof key];+ }+ }+ }+};+const startOfUtcDay = (date: Date) => new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate()));const startOfUtcWeek = (date: Date) => {diff --git a/backend/src/ee/services/insights/insights-service.ts b/backend/src/ee/services/insights/insights-service.tsindex ced69fb4bc..9eca72645f 100644--- a/backend/src/ee/services/insights/insights-service.ts+++ b/backend/src/ee/services/insights/insights-service.ts@@ -45,6 +45,7 @@ import {buildStaticSecretUsageWindow,collapseAccessVolumeDays,resolveUserDisplayNames,+ reviveDates,STALE_SECRET_THRESHOLD_DAYS,toUtcDateString,VALUE_EVENT_TYPES@@ -236,6 +237,10 @@ export const insightsServiceFactory = ({})),reminders};+ },+ reviver: (parsed) => {+ reviveDates(parsed.rotations, "nextRotationAt");+ reviveDates(parsed.reminders, "nextReminderDate");}});};@@ -463,6 +468,13 @@ export const insightsServiceFactory = ({staleSecrets,totalStaleCount};+ },+ reviver: (parsed) => {+ reviveDates(parsed.upcomingRotations, "nextRotationAt");+ reviveDates(parsed.failedRotations, "nextRotationAt");+ reviveDates(parsed.upcomingReminders, "nextReminderDate");+ reviveDates(parsed.overdueReminders, "nextReminderDate");+ reviveDates(parsed.staleSecrets, "updatedAt");}});};