diegosouzapw/OmniRoute · error · Error

getErrorMessage(json, `HTTP `)

Error message

getErrorMessage(json, `HTTP ${res.status}`)

What it means

Thrown when GET /api/providers/health-autopilot returns a non-OK response while the dashboard card loads the autopilot report. It fires on server errors (500), auth rejection, or transient upstream failure; getErrorMessage prefers the API's error payload and falls back to the HTTP status text.

Solutions

  1. Retry the load; the autopilot endpoint is read-only and safe to re-fetch
  2. Check /api/providers/health-autopilot server logs for the underlying failure
  3. Verify the dashboard session/API key is still valid if the status was 401/403
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at src/app/(dashboard)/dashboard/health/ProviderHealthAutopilotCard.tsx:242 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25). Data as JSON: /api/errors/3ab195dbc6d091d9. Report an issue: GitHub.

Appendix: source

Thrown at src/app/(dashboard)/dashboard/health/ProviderHealthAutopilotCard.tsx:242

  );
}

export default function ProviderHealthAutopilotCard() {
  const t = useTranslations("providerHealthAutopilot");
  const nodeMap = useProviderNodeMap();
  const [report, setReport] = useState<AutopilotReport | null>(null);
  const [loading, setLoading] = useState(true);
  const [error, setError] = useState<string | null>(null);
  const [message, setMessage] = useState<string | null>(null);
  const [busyAction, setBusyAction] = useState<string | null>(null);

  const load = useCallback(async () => {
    try {
      const res = await fetch("/api/providers/health-autopilot?includeHealthy=false", {
        cache: "no-store",
      });
      const json = await res.json();
      if (!res.ok) throw new Error(getErrorMessage(json, `HTTP ${res.status}`));
      setReport(json);
      setError(null);
    } catch (err) {
      setError(err instanceof Error ? err.message : t("loadFailed"));
    } finally {
      setLoading(false);
    }
  }, [t]);

  useEffect(() => {
    void load();
    const timer = setInterval(() => void load(), 15000);
    return () => clearInterval(timer);
  }, [load]);

  const topProviders = useMemo(
    () =>
      [...(report?.providers ?? [])].sort((left, right) => left.score - right.score).slice(0, 6),

View on GitHub (pinned to a179ffed5b)