From 250d83de2a2a2951e695c9f0e5ed56d17e4fc5d7 Mon Sep 17 00:00:00 2001 From: Lukasz Raczylo Date: Sun, 29 Nov 2026 00:21:55 +0000 Subject: [PATCH] fix(webui): show provider upstream errors The dashboard ignored upstreamErrors from the admin overview. A provider with a failing modelBaseUrls upstream looked healthy. The provider panel now lists each upstream error, and the breaker rows mark such a provider as degraded. --- webui/src/lib/provider-rate.spec.ts | 24 +++++++++++++++++++++++ webui/src/lib/provider-rate.ts | 30 ++++++++++++++++++++--------- webui/src/panels/ProviderPanel.vue | 5 ++++- webui/src/types/api.ts | 2 ++ 4 files changed, 51 insertions(+), 10 deletions(-) diff --git a/webui/src/lib/provider-rate.spec.ts b/webui/src/lib/provider-rate.spec.ts index 290df33..11eea37 100644 --- a/webui/src/lib/provider-rate.spec.ts +++ b/webui/src/lib/provider-rate.spec.ts @@ -221,6 +221,30 @@ describe('breakerRows', () => { it('returns nothing without an overview', () => { expect(breakerRows(null)).toEqual([]) }) + + it('breakerRows marks a closed provider with upstreamErrors as degraded', () => { + const rows = breakerRows({ providers: [{ ...p('a', 'closed'), upstreamErrors: [{ upstream: 'http://x', error: 'boom' }] }] }) + expect(rows[0]!.degraded).toBe(true) + }) + + it('breakerRows shows the first upstream error when lastErr is empty', () => { + const errs = [ + { upstream: 'http://x', error: 'boom' }, + { upstream: 'http://y', error: 'bang' }, + ] + const [one] = breakerRows({ providers: [{ ...p('a', 'closed'), upstreamErrors: errs.slice(0, 1) }] }) + expect(one!.lastErr).toBe('http://x: boom') + const [two] = breakerRows({ providers: [{ ...p('a', 'closed'), upstreamErrors: errs }] }) + expect(two!.lastErr).toBe('http://x: boom (+1 more)') + const [own] = breakerRows({ providers: [{ ...p('a', 'closed', { lastErr: 'real' }), upstreamErrors: errs }] }) + expect(own!.lastErr).toBe('real') + }) + + it('breakerRows keeps a closed provider with neither healthy', () => { + const [row] = breakerRows({ providers: [{ ...p('a', 'closed'), upstreamErrors: [] }] }) + expect(row!.degraded).toBe(false) + expect(row!.lastErr).toBe('') + }) }) describe('ratePercentSeries', () => { diff --git a/webui/src/lib/provider-rate.ts b/webui/src/lib/provider-rate.ts index abdaeb3..6649170 100644 --- a/webui/src/lib/provider-rate.ts +++ b/webui/src/lib/provider-rate.ts @@ -180,11 +180,11 @@ export interface BreakerRow { state: ProviderHealthState openUntil: string lastErr: string - /** Closed breaker that still reports a last error. */ + /** Closed breaker that still reports a last error or a failing upstream. */ degraded: boolean } -type BreakerSource = Pick +type BreakerSource = Pick const BREAKER_STATE_ORDER: Record = { open: 0, 'half-open': 1, closed: 2 } @@ -193,15 +193,27 @@ function breakerTier(r: BreakerRow): number { return r.state === 'closed' && !r.degraded ? 3 : BREAKER_STATE_ORDER[r.state] } +/** The last error, or the first upstream error (with a count of the rest) when there is none. */ +function breakerErrText(p: BreakerSource): string { + if (p.lastErr) return p.lastErr + const ups = p.upstreamErrors ?? [] + if (ups.length === 0) return '' + const first = `${ups[0]!.upstream}: ${ups[0]!.error}` + return ups.length > 1 ? `${first} (+${ups.length - 1} more)` : first +} + /** One row per provider, ordered open, half-open, degraded, healthy; ties by name. */ export function breakerRows(overview: { providers: ReadonlyArray } | null): BreakerRow[] { - const rows = (overview?.providers ?? []).map((p) => ({ - provider: p.name, - state: p.healthState, - openUntil: p.openUntil, - lastErr: p.lastErr ?? '', - degraded: p.healthState === 'closed' && !!p.lastErr, - })) + const rows = (overview?.providers ?? []).map((p) => { + const lastErr = breakerErrText(p) + return { + provider: p.name, + state: p.healthState, + openUntil: p.openUntil, + lastErr, + degraded: p.healthState === 'closed' && lastErr !== '', + } + }) return rows.sort((a, b) => breakerTier(a) - breakerTier(b) || a.provider.localeCompare(b.provider)) } diff --git a/webui/src/panels/ProviderPanel.vue b/webui/src/panels/ProviderPanel.vue index 1186120..27682db 100644 --- a/webui/src/panels/ProviderPanel.vue +++ b/webui/src/panels/ProviderPanel.vue @@ -78,7 +78,10 @@ function showAll(): void {

{{ provider.lastErr }}

-

No error recorded.

+
    +
  • {{ e.upstream }}: {{ e.error }}
  • +
+

No error recorded.

diff --git a/webui/src/types/api.ts b/webui/src/types/api.ts index d3b329c..5d12735 100644 --- a/webui/src/types/api.ts +++ b/webui/src/types/api.ts @@ -103,6 +103,8 @@ export interface AdminProviderView { baseUrl: string lastRefresh: string lastErr?: string + /** modelBaseUrls upstreams whose discovery failed while the provider stayed healthy (admin.go: adminProviderView.UpstreamErrors). */ + upstreamErrors?: Array<{ upstream: string; error: string }> /** Sorted explicit∪discovered model ids (admin.go: adminProviderView.Models) — always an array, never omitted, even when empty. */ models: string[] /** Display labels from the provider's `kinds` config, keyed by model id or endpoint path (admin.go: adminProviderView.Kinds). */