Skip to content

fix(logger): accept resolvable IANA timezone aliases in timestamps - #5458

Merged
svozza merged 1 commit into
mainfrom
fix/logger-timezone-alias-fallback
Jul 13, 2026
Merged

fix(logger): accept resolvable IANA timezone aliases in timestamps#5458
svozza merged 1 commit into
mainfrom
fix/logger-timezone-alias-fallback

Conversation

@dreamorosi

Copy link
Copy Markdown
Contributor

Summary

The Logger validated the TZ timezone against Intl.supportedValuesOf('timeZone'), which contains canonical identifiers only. Valid IANA aliases like Asia/Kolkata (the IANA primary name for India) were silently rejected, producing timestamps with UTC clock digits but a local offset suffix — i.e. the wrong instant. This PR switches to resolution-based validation, delegating alias knowledge entirely to Intl.DateTimeFormat, and makes the UTC fallback internally consistent and no longer silent.

Changes

  • Replace the Intl.supportedValuesOf('timeZone') membership check in LogFormatter with a try/catch around Intl.DateTimeFormat construction, so any timezone ICU can resolve (canonical or alias) is accepted; this also stays correct when future ICU versions flip the canonical list to IANA primary names (ECMA-402 change)
  • Force the offset suffix to +00:00 when falling back to UTC, so an unresolvable TZ (e.g. :/etc/localtime, preserving the fix for Bug: logger breaks on nodejs Docker lambdas since 2.4.0 #2851) can no longer produce a timestamp mixing UTC digits with a non-zero local offset
  • Emit a one-time warning per formatter instance when falling back to UTC, instead of substituting the timezone silently
  • Add unit tests covering the Asia/Kolkata alias, offset consistency on fallback, and the one-time warning

Issue number: closes #5456


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

…k timestamps consistent

Replace the Intl.supportedValuesOf('timeZone') membership check with
resolution-based validation via Intl.DateTimeFormat construction. The
canonical-only list rejected valid aliases such as Asia/Kolkata, causing
timestamps to mix UTC clock digits with the local offset and denote the
wrong instant. Resolution-based validation also stays correct when future
ICU versions flip the canonical list to IANA primary names.

When the timezone cannot be resolved (e.g. TZ=:/etc/localtime), fall back
to UTC for both the date digits and the offset suffix, and emit a one-time
warning instead of failing silently.

Fixes #5456
@sonarqubecloud

Copy link
Copy Markdown

@dreamorosi
dreamorosi requested a review from svozza July 13, 2026 09:37
@svozza
svozza merged commit 4cdc936 into main Jul 13, 2026
120 of 121 checks passed
@svozza
svozza deleted the fix/logger-timezone-alias-fallback branch July 13, 2026 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L PRs between 100-499 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Logger silently falls back to UTC for valid IANA timezone aliases (e.g. TZ=Asia/Kolkata)

2 participants