Skip to content

fix(studio): render alert last-triggered time as UTC - #4199

Closed
jokerzsd wants to merge 1 commit into
apache:rocketmq-studiofrom
jokerzsd:fix/studio-alert-utc-timestamp
Closed

jokerzsd wants to merge 1 commit into
apache:rocketmq-studiofrom
jokerzsd:fix/studio-alert-utc-timestamp

Conversation

@jokerzsd

@jokerzsd jokerzsd commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix the alert rule "最近触发时间" (last-triggered) column rendering a UTC timestamp as browser-local time.

Problem

The backend stamps lastTriggered as a UTC LocalDateTime without an offset suffix (e.g. 2026-08-23T23:30:00). The rule page rendered it with formatDateTime, which parses offset-less ISO strings with new Date(...) as browser-local time. A rule that fired at 23:30 UTC showed 23:30 in every timezone.

Fix

Use formatUtcDateTime (already used by the system-alert page), which appends Z to offset-less strings so they are parsed as UTC. This also covers /ops/business-alerts, which reuses the same AlertsPage component.

Test plan

cd web && npx tsc -b passes.

Fixes #4174

The backend stamps lastTriggered as a UTC LocalDateTime without an
offset suffix, but the alert rule page rendered it with formatDateTime,
which parses offset-less ISO strings as browser-local time. A rule fired
at 23:30 UTC then showed 23:30 in every timezone. Use formatUtcDateTime,
matching the system-alert page, so the value is treated as UTC.

Fixes apache#4174

Signed-off-by: jokerzsd <2701819133@qq.com>

@RockteMQ-AI RockteMQ-AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

Fix timezone inconsistency in alert last-triggered display — the column was using formatDateTime (local time) while the tooltip and lastTriggeredMs both use UTC. Switching to formatUtcDateTime makes the column consistent with the rest of the timestamp handling.

Clean one-line fix, correctly references issue #4174. LGTM.


Automated review by github-manager-bot

@lizhimins

Copy link
Copy Markdown
Member

Closing as a duplicate of #4175, merged into rocketmq-studio as 6334f92. Both switch alerts.tsx from formatDateTime to formatUtcDateTime, but #4175 also updates the two existing assertions in AlertsPage.test.tsx (:25, :232); this patch leaves them expecting the old format, so merging it on its own would have turned the suite red.

@lizhimins lizhimins closed this Sep 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants