Skip to content

Channel diagnostics card shown incorrectly when channel is healthy due to Go zero-value time serialization #1143

Description

@dpy1123

Problem

The "What happened" diagnostics card on the channel detail page is displayed even when the channel is in a healthy state. This makes it look like something is wrong when the channel is actually operating normally.

Root Cause

The showDiagnosticsCard condition in channel-detail-page.tsx includes:

const showDiagnosticsCard =
    status?.state === "failed" ||
    status?.state === "degraded" ||
    !!status?.remediation ||
    !!status?.consecutive_failures ||
    !!status?.first_failed_at;    // ← bug here

The backend (mergeChannelHealth in internal/channels/health.go) correctly resets FirstFailedAt to time.Time{} when the channel transitions back to healthy. However, Go's zero-value time.Time{} serializes to "0001-01-01T00:00:00Z" in JSON — it does not become null or get omitted (the struct tag has no omitempty, and omitempty doesn't work for time.Time in Go's standard library anyway).

On the frontend, !!status?.first_failed_at evaluates !!"0001-01-01T00:00:00Z"true, so the diagnostics card is always shown for any channel that has ever experienced a failure, even if it has fully recovered.

Fix

Replace the raw truthy check with the existing formatRelativeTime() helper, which already filters out year≤ 1 timestamps:

import { formatRelativeTime } from "../channels-status-view";

const showDiagnosticsCard =
    status?.state === "failed" ||
    status?.state === "degraded" ||
    !!status?.remediation ||
    !!status?.consecutive_failures ||
    !!formatRelativeTime(status?.first_failed_at);

formatRelativeTime("0001-01-01T00:00:00Z") returns null because of its existing guard:

if (date.getUTCFullYear() <= 1) return null;

This ensures the diagnostics card only appears when there is a meaningful active or recent failure.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3-lowMinor bug, cosmetic, compatibility — backlogarea:channelsTelegram, Discord, channel managerbugSomething isn't workingux

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions