{"record":{"id":"40e811af35b6650f","repo":"moeru-ai/airi","slug":"failed-to-initialize-aliyun-nls-provider","errorCode":null,"errorMessage":"Failed to initialize Aliyun NLS provider.","messagePattern":"Failed to initialize Aliyun NLS provider\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/stage-pages/src/pages/settings/providers/transcription/aliyun-nls-transcription.vue","lineNumber":228,"sourceCode":"  errorMessage.value = null\n  resetTranscriptionOutput()\n\n  const abortController = new AbortController()\n  transcriptionAbortController.value = abortController\n\n  const audioStream = new ReadableStream<ArrayBuffer>({\n    start(controller) {\n      audioStreamController.value = controller\n    },\n    cancel: () => {\n      audioStreamController.value = undefined\n    },\n  })\n\n  try {\n    const provider = await providersStore.getProviderInstance<TranscriptionProviderWithExtraOptions<string, any>>(providerId)\n    if (!provider)\n      throw new Error('Failed to initialize Aliyun NLS provider.')\n\n    const result = await hearingStore.transcription(\n      providerId,\n      provider,\n      defaultModel,\n      { inputAudioStream: audioStream },\n      undefined,\n      {\n        providerOptions: {\n          abortSignal: abortController.signal,\n          hooks: {\n            onServerEvent: (event: ServerEvent) => {\n              handleServerEvent(event)\n            },\n          },\n          onSessionTerminated: async (error?: unknown) => {\n            if (error)\n              errorMessage.value = errorMessageFromValue(error)","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/moeru-ai/airi/blob/677329427f32468c74b17f3ec47eeca4e05bec65/packages/stage-pages/src/pages/settings/providers/transcription/aliyun-nls-transcription.vue#L210-L246","documentation":"Thrown by the Aliyun NLS streaming-transcription playground when `getProviderInstance('aliyun-nls-transcription')` resolves falsy before starting a realtime session. The Aliyun definition requires accessKeyId, accessKeySecret, and appKey (plus a region enum, default 'cn-shanghai'); its own factory throws 'Aliyun NLS credentials are incomplete.' for blank fields, and the store throws separately for missing config/definition — so this message catches the residual case where an instance still comes back null/undefined (factory or bridge regression, or a config shape that bypasses the explicit checks).","triggerScenarios":"Starting stream transcription with one of accessKeyId/accessKeySecret/appKey blank; credentials saved as whitespace strings; a region value outside the supported enum surviving into config; factory/unspeech regression returning undefined instead of throwing its incomplete-credentials error.","commonSituations":"Creating an Aliyun NLS project and app key but pasting only part of the triple; rotating AccessKeys in the Aliyun console without updating all three fields; internal vs public region endpoints confusion (cn-shanghai vs cn-shanghai-internal); first-time setup where validation was skipped via force.","solutions":["Fill all three credentials (Access Key ID, Access Key Secret, App Key) in the provider settings — the built-in validator flags each missing one.","Pick a supported region from the enum (e.g. cn-shanghai, cn-beijing, cn-shenzhen) — use non-internal variants from a client machine.","Re-run the stream after saving; the instance cache is per-session so a reload guarantees a rebuild.","Check the console for the factory's own messages ('Aliyun NLS credentials are incomplete.') or the store's `Error creating provider instance for ...` log.","If all three fields are valid and it still hits this line, report it as a factory contract bug."],"exampleFix":"// before\nconst provider = await providersStore.getProviderInstance<TranscriptionProviderWithExtraOptions<string, any>>(providerId)\nif (!provider)\n  throw new Error('Failed to initialize Aliyun NLS provider.')\n\n// after\nconst config = providerStore.getProviderConfig(providerId)\nif (!config?.accessKeyId?.trim() || !config?.accessKeySecret?.trim() || !config?.appKey?.trim())\n  throw new Error('Aliyun NLS needs Access Key ID, Access Key Secret, and App Key before streaming.')\nconst provider = await providersStore.getProviderInstance<TranscriptionProviderWithExtraOptions<string, any>>(providerId)\nif (!provider || typeof provider.transcription !== 'function')\n  throw new Error('Aliyun NLS factory returned no usable instance — check credentials and console logs')","handlingStrategy":"validation","validationCode":"const credentialsReady = computed(() => {\n  const c = providers.value[providerId]\n  return !!c?.accessKeyId?.trim() && !!c?.accessKeySecret?.trim() && !!c?.appKey?.trim()\n})\nif (!credentialsReady.value)\n  throw new Error('Aliyun NLS needs Access Key ID, Access Key Secret, and App Key')","typeGuard":"function isTranscriptionProvider(v: unknown): v is TranscriptionProviderWithExtraOptions<string, any> {\n  return typeof v === 'object' && v !== null && typeof (v as TranscriptionProviderWithExtraOptions<string, any>).transcription === 'function'\n}","tryCatchPattern":"try { const provider = await providersStore.getProviderInstance(providerId) }\ncatch (error) {\n  // 'Aliyun NLS credentials are incomplete.' and 'Provider credentials ... not found'\n  // both surface here — show them verbatim; they name the exact missing field class\n  errorMessage.value = errorMessageFromValue(error)\n}","preventionTips":["Complete all three credential fields before starting a stream.","Use a public region (not -internal) from client machines.","Run the built-in config validator before first use."],"tags":["transcription","provider","initialization","credentials","aliyun"],"backgroundTag":"provider-instance-undefined","analyzedSha":"677329427f32468c74b17f3ec47eeca4e05bec65","analyzedAt":"2026-08-18T17:29:58.153Z","contentChangedAt":"2026-08-18T17:29:58.153Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}