{"record":{"id":"81c25b3ad1672335","repo":"moeru-ai/airi","slug":"streaming-models-upstream-missing-models","errorCode":null,"errorMessage":"streaming models upstream missing models[]","messagePattern":"streaming models upstream missing models\\[\\]","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/stage-ui/src/libs/providers/providers/official/index.ts","lineNumber":261,"sourceCode":"  validationRequiredWhen: () => false,\n  extraMethods: {\n    listModelCatalog: listStreamingModelCatalog,\n    listModels: async () => (await listStreamingModelCatalog()).models,\n    voiceCatalogConfig: () => ({}),\n    listVoices: async (_config, _provider, model, signal): Promise<VoiceInfo[]> => {\n      // Streaming voices live behind a dedicated endpoint\n      // (`/audio/voices/streaming`) because they come from the\n      // `UNSPEECH_UPSTREAM.streaming` configKV subtree rather than the HTTP TTS\n      // `?model=...` lookup. The server proxies to unspeech's\n      // `/api/voices?provider=volcengine`, which ships an embed-time\n      // catalogue without requiring credentials.\n      //\n      // `model` here is the unspeech-routed id (e.g. `volcengine/seed-tts-2.0`).\n      // unspeech expects the bare `api_resource_id` for its filter, so we\n      // strip the backend prefix before forwarding.\n      const apiResourceId = model?.includes('/') ? model.split('/', 2)[1] : model\n      const voicesURL = new URL(`${SERVER_URL}/api/v1/audio/voices/streaming`)\n      if (apiResourceId)\n        voicesURL.searchParams.set('model', apiResourceId)\n      const res = await globalThis.fetch(\n        voicesURL.toString(),\n        { headers: authHeaders(), signal },\n      )\n      if (!res.ok)\n        throw new Error(`streaming voices upstream ${res.status}: ${await res.text().catch(() => '')}`.slice(0, 256))\n\n      const data = await res.json() as {\n        voices?: {\n          id: string\n          name: string\n          description?: string\n          labels?: Record<string, unknown>\n          languages?: { code: string, title: string }[]\n          preview_audio_url?: string\n        }[]\n        recommended?: Record<string, string>","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/moeru-ai/airi/blob/438a067dde47aa0bdb46c2323d1fe293dc805218/packages/stage-ui/src/libs/providers/providers/official/index.ts#L243-L279","documentation":"Thrown by the official streaming speech provider's `listModels()` when `/api/v1/audio/models/streaming` returned 200 but `data.models` is not an array. The declared type marks `models` as required (unlike the HTTP provider where it is optional), so any 200 body without `models[]` violates the contract and aborts model discovery.","triggerScenarios":"Server answers 200 with `{ available: false }` and no `models` key; an older server shape (e.g. plain array or different key) after version skew; a proxy rewriting error pages to 200.","commonSituations":"Client newer than server during staged rollout; `STREAMING_TTS_UPSTREAM` half-configured so the gateway reports availability metadata without a model catalog; API edge returning 200 JSON errors.","solutions":["Inspect the raw response body via curl to see the actual shape returned.","Deploy matching server/client revisions — the client expects `{ available, models: [{id,name,description}], default }`.","If the server intentionally reports no models, have it return an empty `models: []` array rather than omitting the field.","Treat this failure as 'streaming unavailable' in callers so the UI degrades gracefully."],"exampleFix":"// before\nif (!Array.isArray(data.models))\n  throw new Error('streaming models upstream missing models[]')\n// after — honor the availability flag and tolerate a missing catalog\nif (!Array.isArray(data.models)) {\n  streamingTtsAvailable.value = false\n  return []\n}","handlingStrategy":"type-guard","validationCode":"const data: unknown = await res.json()\nif (!isStreamingModelsPayload(data))\n  streamingTtsAvailable.value = false","typeGuard":"function isStreamingModelsPayload(data: unknown): data is { available?: boolean, models: Array<{ id: string, name?: string, description?: string }>, default?: string | null } {\n  if (typeof data !== 'object' || data === null)\n    return false\n  return Array.isArray((data as { models?: unknown }).models)\n}","tryCatchPattern":"const models = isStreamingModelsPayload(data)\n  ? data.models.map(toModelInfo)\n  : []","preventionTips":["Server should always include `models` (empty array when none) — make that an API invariant.","Contract-test the streaming models payload shape on the server.","Tolerate a missing catalog while honoring the `available` flag.","Deploy server and client revisions together."],"tags":["schema","validation","api","server","streaming"],"backgroundTag":"schema-validation-failed","analyzedSha":"438a067dde47aa0bdb46c2323d1fe293dc805218","analyzedAt":"2026-08-18T17:29:58.153Z","contentChangedAt":"2026-08-18T17:29:58.153Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}