From 847b6da9dc76788cf41f4b6d011c4be7db900d55 Mon Sep 17 00:00:00 2001 From: manganate006 Date: Wed, 25 Feb 2026 17:16:35 +0100 Subject: [PATCH] fix: prevent ghost changes when SSL data is empty or invalid When SSL certificate fetch fails (timeout, network error), the fresh values are empty strings. The date comparison logic was triggering isNaN(diffInDays) which recorded a "change" with empty old/new values, polluting the change history. This fix: - Skips recording changes when both old and new values are empty - Skips recording changes when new date value is invalid/empty (NaN case) - Prevents ghost entries in domain_updates table --- .../routes/domain-updater/updateFns/ssl.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/server/routes/domain-updater/updateFns/ssl.ts b/src/server/routes/domain-updater/updateFns/ssl.ts index 7156399c..fa5863e5 100644 --- a/src/server/routes/domain-updater/updateFns/ssl.ts +++ b/src/server/routes/domain-updater/updateFns/ssl.ts @@ -74,7 +74,11 @@ export async function updateSSL( newVal = normalizeStr(newVal); } - + // Skip if both values are empty (no real change) + if (!oldVal && !newVal) { + continue; + } + // Special date comparison, because timezones are stupid if (field.type === 'date') { const oldDate = new Date(oldVal); @@ -83,6 +87,12 @@ export async function updateSSL( const diffInMs = Math.abs(newDate.getTime() - oldDate.getTime()); const diffInDays = diffInMs / (1000 * 60 * 60 * 24); + // Skip if new value is invalid/empty (NaN means we couldn't parse the new date) + // This prevents ghost changes when SSL fetch fails + if (isNaN(diffInDays) && !newVal) { + continue; + } + if (isNaN(diffInDays) || diffInDays > 1) { updateSet.push(`${field.column} = $${updateSet.length + 2}::date`); updateValues.push(toDateOnly(newVal)); @@ -92,6 +102,11 @@ export async function updateSSL( } if (oldVal !== newVal && field.type != 'date') { + // Skip recording if new value is empty (likely a fetch failure, not a real change) + if (!newVal && oldVal) { + continue; + } + updateSet.push(`${field.column} = $${updateSet.length + 2}::${field.type}`); updateValues.push(field.new ?? null);