fix(07.1-02): allowlist UTC, Etc/UTC, GMT in IANA validator

This commit is contained in:
lorentz 2026-05-07 17:21:26 -04:00
parent f55b937af9
commit 660d039b80

View file

@ -17,8 +17,15 @@ function getDefaultTimezone(): string {
return process.env.DEFAULT_TIMEZONE || 'UTC';
}
// Node's Intl.supportedValuesOf('timeZone') returns canonical IANA zones only —
// it omits 'UTC', 'Etc/UTC', 'GMT', and the entire Etc/* alias namespace, even
// though those are valid for Postgres AT TIME ZONE and JS Date methods. The
// migration default is 'UTC', so the validator must accept it explicitly.
const EXTRA_ALLOWED_TIMEZONES = new Set(['UTC', 'Etc/UTC', 'GMT', 'Etc/GMT']);
function isValidIanaTimezone(tz: unknown): tz is string {
if (typeof tz !== 'string' || tz.length === 0 || tz.length > 64) return false;
if (EXTRA_ALLOWED_TIMEZONES.has(tz)) return true;
try {
const zones = Intl.supportedValuesOf('timeZone');
return zones.includes(tz);