{"record":{"id":"bec151a65689aef2","repo":"moeru-ai/airi","slug":"failed-to-initialize-transcription-provider-bec151","errorCode":null,"errorMessage":"Failed to initialize transcription provider","messagePattern":"Failed to initialize transcription provider","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/stage-pages/src/pages/settings/providers/transcription/openai-audio-transcription.vue","lineNumber":56,"sourceCode":"\nconst isLoadingModels = computed(() => {\n  return providersStore.isLoadingModels[providerId] || false\n})\n\n// Check if API key is configured\nconst apiKeyConfigured = computed(() => !!providers.value[providerId]?.apiKey)\n\n// Load models on mount\nonMounted(async () => {\n  await providersStore.loadModelsForConfiguredProviders()\n  await providersStore.fetchModelsForProvider(providerId)\n})\n\n// Generate transcription\nasync function handleGenerateTranscription(file: File) {\n  const provider = await providersStore.getProviderInstance<TranscriptionProviderWithExtraOptions<string, any>>(providerId)\n  if (!provider) {\n    throw new Error('Failed to initialize transcription provider')\n  }\n\n  // Get provider configuration\n  const providerConfig = providerStore.getProviderConfig(providerId)\n\n  // Get model from configuration or use default\n  const modelToUse = providerConfig.model as string | undefined || defaultModel\n\n  return await hearingStore.transcription(\n    providerId,\n    provider,\n    modelToUse,\n    file,\n    'json',\n  )\n}\n\nwatch(model, async () => {","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/moeru-ai/airi/blob/677329427f32468c74b17f3ec47eeca4e05bec65/packages/stage-pages/src/pages/settings/providers/transcription/openai-audio-transcription.vue#L38-L74","documentation":"Thrown by the OpenAI audio transcription settings page when providersStore.getProviderInstance() resolves to a falsy value for the configured providerId. The provider factory in the stage-ui providers registry either could not find a registered provider definition for that id, or refused to construct an instance (for example because the API key was never persisted). It is a setup/dependency error, not a network error: nothing was sent to OpenAI yet.","triggerScenarios":"Calling handleGenerateTranscription (pressing Generate in the transcription settings page) while providers.value[providerId]?.apiKey is empty, the provider was never initialized via initializeProvider(providerId), or the provider id is not present in the registry consumed by getProviderInstance.","commonSituations":"User opens the transcription settings tab and clicks Generate before entering/saving an API key; localStorage/persisted provider settings were cleared; the providerId constant drifted out of sync with the registered provider key after a refactor; provider settings live in a different app (stage-web vs stage-tamagotchi) and were never configured there.","solutions":["Enter and save an API key for the provider in the settings page, then retry generation (apiKeyConfigured computed must be true).","Verify providerId matches the key registered in packages/stage-ui/src/stores/providers.ts / stores/providers/ definitions.","Check that onMounted's initializeProvider/fetchModels flow ran without errors (look for earlier console failures) before invoking generation.","If importing a custom provider, confirm its factory is registered in the providers registry consumed by getProviderInstance."],"exampleFix":"// before\nconst provider = await providersStore.getProviderInstance<TranscriptionProviderWithExtraOptions<string, any>>(providerId)\nif (!provider) {\n  throw new Error('Failed to initialize transcription provider')\n}\n\n// after — surface the actionable cause instead of a generic message\nconst provider = await providersStore.getProviderInstance<TranscriptionProviderWithExtraOptions<string, any>>(providerId)\nif (!provider) {\n  throw new Error(`Failed to initialize transcription provider \"${providerId}\". ${apiKeyConfigured.value ? 'Provider is not registered.' : 'Save an API key for this provider first.'}`)\n}","handlingStrategy":"validation","validationCode":"const configured = computed(() => !!providers.value[providerId]?.apiKey)\nif (!configured.value) {\n  // show 'save an API key first' UI instead of attempting generation\n}\nconst provider = configured.value\n  ? await providersStore.getProviderInstance<TranscriptionProviderWithExtraOptions<string, any>>(providerId)\n  : null","typeGuard":"function isTranscriptionProviderReady(\n  settings: { apiKey?: string } | undefined,\n  instance: unknown,\n): instance is TranscriptionProviderWithExtraOptions<string, any> {\n  return !!settings?.apiKey && instance != null\n}","tryCatchPattern":"try {\n  await handleGenerateTranscription(file)\n}\ncatch (error) {\n  if (errorMessageFrom(error).includes('Failed to initialize transcription provider')) {\n    // prompt user to complete provider settings; do not retry with same state\n  }\n  throw error\n}","preventionTips":["Gate the Generate button on apiKeyConfigured so the provider factory is never invoked without credentials.","Run initializeProvider(providerId) in onMounted before any generation is possible.","Fail fast in provider registries with a specific reason when getProviderInstance returns null."],"tags":["provider-initialization","configuration","api-key","transcription"],"backgroundTag":"provider-initialization-failed","analyzedSha":"677329427f32468c74b17f3ec47eeca4e05bec65","analyzedAt":"2026-08-18T17:29:58.153Z","contentChangedAt":"2026-08-18T17:29:58.153Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}