{"record":{"id":"4e39a4b7f564b777","repo":"moeru-ai/airi","slug":"streaming-models-upstream-res-status-await-r","errorCode":null,"errorMessage":"streaming models upstream ${res.status}: ${await res.text().catch(() => '')}","messagePattern":"streaming models upstream (.+?): (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/stage-ui/src/libs/providers/providers/official/index.ts","lineNumber":30,"sourceCode":"\nconst officialConfigSchema = z.object({})\n\nfunction authHeaders(): Record<string, string> {\n  const headers: Record<string, string> = { Accept: 'application/json' }\n  const token = getAuthToken()\n  if (token)\n    headers.Authorization = `Bearer ${token}`\n  return headers\n}\n\nasync function listStreamingModelCatalog(): Promise<ProviderModelCatalog> {\n  // Streaming TTS catalog is operator-controlled via configKV\n  // (`UNSPEECH_UPSTREAM.streaming`). Wire shape uses `<backend>/<api_resource_id>`\n  // (see `unspeech/docs/wire-protocols/audio-speech-stream-v1.md`); the\n  // server returns whatever the operator put there, no client-side defaults.\n  const res = await globalThis.fetch(`${SERVER_URL}/api/v1/audio/models/streaming`, { headers: authHeaders() })\n  if (!res.ok)\n    throw new Error(`streaming models upstream ${res.status}: ${await res.text().catch(() => '')}`.slice(0, 256))\n\n  const data = await res.json() as {\n    available: boolean\n    models: { id: string, name?: string, description?: string }[]\n    default: string | null\n  }\n\n  return {\n    available: data.available,\n    defaultModel: data.default ?? null,\n    models: data.models.map(m => ({\n      id: m.id,\n      name: m.name ?? m.id,\n      provider: OFFICIAL_SPEECH_STREAMING_PROVIDER_ID,\n      description: m.description,\n    })),\n  }\n}","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/moeru-ai/airi/blob/438a067dde47aa0bdb46c2323d1fe293dc805218/packages/stage-ui/src/libs/providers/providers/official/index.ts#L12-L48","documentation":"Thrown by the official streaming speech provider's `listModels()` when `GET ${SERVER_URL}/api/v1/audio/models/streaming` replies non-2xx. This probe also drives `streamingTtsAvailable` — the flag is reset to `false` before the fetch so a failed probe hides the provider instead of leaving a stale 'available'. Typical statuses: 401 (no/expired bearer token) or 5xx (server-side `STREAMING_TTS_UPSTREAM` not configured/unreachable).","triggerScenarios":"Probing streaming models while signed out or with an expired JWT; server revision without the `/models/streaming` route (404); `STREAMING_TTS_UPSTREAM` unset or its upstream down, surfacing as 502/503 from the gateway.","commonSituations":"Fresh sign-in flow where the probe races token refresh; self-hosted deployment that never configured streaming TTS but runs a new client that probes it; partial outage of the volcengine/other streaming upstream behind the gateway.","solutions":["Ensure the user is authenticated before the probe runs (the UI should hide streaming until signed in).","curl `/api/v1/audio/models/streaming` with a bearer token to see the real status and body.","On the server, set `STREAMING_TTS_UPSTREAM` with a valid backend, or expect this probe to fail and keep the streaming provider hidden (that is by design).","Update both server and client so the route and the `available`/`models[]` contract match."],"exampleFix":"// before\nconst models = await streamingProvider.extraMethods.listModels()\n// after — treat a failed probe as 'streaming unavailable' instead of an error\nlet models: ModelInfo[] = []\ntry {\n  models = await streamingProvider.extraMethods.listModels()\n}\ncatch (error) {\n  console.warn('streaming TTS unavailable', error)\n}","handlingStrategy":"try-catch","validationCode":"const token = getAuthToken()\nif (!token)\n  return { models: [], available: false } // skip the probe entirely","typeGuard":null,"tryCatchPattern":"try {\n  models = await streamingProvider.extraMethods.listModels()\n}\ncatch (error) {\n  console.warn('streaming TTS probe failed — keeping provider hidden', error)\n  models = []\n}","preventionTips":["Only probe the streaming endpoint after sign-in.","Remember a failed probe is the designed 'unavailable' path (`streamingTtsAvailable` stays false) — do not surface it as a user error.","Configure `STREAMING_TTS_UPSTREAM` on servers that should offer streaming TTS.","Cache the probe result per session to avoid repeated failing calls."],"tags":["network","api","auth","server","streaming","tts"],"backgroundTag":"upstream-api-error","analyzedSha":"438a067dde47aa0bdb46c2323d1fe293dc805218","analyzedAt":"2026-09-08T13:18:15.005Z","contentChangedAt":"2026-09-08T13:18:15.005Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}