{"record":{"id":"1fa2860272a04ab9","repo":"iOfficeAI/AionUi","slug":"stt-request-failed","errorCode":"STT_REQUEST_FAILED","errorMessage":"payload.msg || 'STT_REQUEST_FAILED'","messagePattern":"payload\\.msg \\|\\| 'STT_REQUEST_FAILED'","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/desktop/src/renderer/services/SpeechToTextService.ts","lineNumber":52,"sourceCode":"const createAudioFileName = (mimeType: string) => {\n  return `speech-input.${getAudioExtension(mimeType)}`;\n};\n\nconst ensureAudioSize = (blob: Blob) => {\n  if (blob.size > MAX_AUDIO_FILE_SIZE_BYTES) {\n    throw new Error('STT_FILE_TOO_LARGE');\n  }\n};\n\nconst parseSuccessResponse = (response: XMLHttpRequest): SpeechToTextResult => {\n  const payload = JSON.parse(response.responseText) as {\n    data?: SpeechToTextResult;\n    msg?: string;\n    success: boolean;\n  };\n\n  if (!payload.success || !payload.data) {\n    throw new Error(payload.msg || 'STT_REQUEST_FAILED');\n  }\n\n  return payload.data;\n};\n\n// Surface the backend error code (STT_DISABLED, STT_OPENAI_NOT_CONFIGURED, ...)\n// so useSpeechInput can map it to a localized error state.\nconst parseErrorResponse = (response: XMLHttpRequest): Error => {\n  if (response.status === 413) {\n    return new Error('STT_FILE_TOO_LARGE');\n  }\n\n  try {\n    const payload = JSON.parse(response.responseText) as { code?: string; error?: string; msg?: string };\n    const code = payload.code;\n    const detail = payload.error || payload.msg;\n    if (code || detail) {\n      return new Error([code, detail].filter(Boolean).join(': '));","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/iOfficeAI/AionUi/blob/711aa0550ee183ea495dc33e2c05c7943b70a60a/packages/desktop/src/renderer/services/SpeechToTextService.ts#L34-L70","documentation":"`parseSuccessResponse` inspects the STT backend's JSON envelope; if `success` is false or `data` is missing it throws with the backend `msg` (or the generic `STT_REQUEST_FAILED`). This is the server-side rejection path for transcription requests that completed at HTTP level but failed logically.","triggerScenarios":"The STT HTTP request returns 200 with `{success:false, msg?}` or a payload lacking `data` — e.g. backend STT disabled, OpenAI key not configured, transcription provider error, or malformed response JSON.","commonSituations":"STT not enabled in backend config (STT_DISABLED); OpenAI credentials missing (STT_OPENAI_NOT_CONFIGURED); upstream transcription provider outage or quota exhaustion; proxy/gateway stripping the response body so data is absent.","solutions":["Read the thrown message — it usually carries the backend code (STT_DISABLED, STT_OPENAI_NOT_CONFIGURED, etc.) and tells you exactly what to configure","Enable STT and configure the required provider credentials in backend settings","Verify network/proxy isn't mangling the JSON response","Retry after fixing config; transient provider errors can justify one retry with backoff"],"exampleFix":"// before\nif (!payload.success || !payload.data) {\n  throw new Error(payload.msg || 'STT_REQUEST_FAILED');\n}\n\n// after (map backend codes to user-facing messages)\nif (!payload.success || !payload.data) {\n  throw new Error(payload.msg || 'STT_REQUEST_FAILED'); // wrap caller:\n}\n// caller: catch (e) { showToast(mapSttErrorCode(e.message)); }","handlingStrategy":"fallback","validationCode":"// nothing client-side can guarantee backend success; verify config first\nawait ensureSttEnabled(); // checks backend STT config before recording","typeGuard":"type SttEnvelope = { success: boolean; data?: SpeechToTextResult; msg?: string };\nconst isSttSuccess = (p: SttEnvelope): p is { success: true; data: SpeechToTextResult } => p.success && !!p.data;","tryCatchPattern":"catch (e) { showToast(mapSttErrorCode(e.message)); // handles STT_DISABLED, STT_OPENAI_NOT_CONFIGURED, ... }","preventionTips":["Check STT backend status before enabling the mic button","Map known backend codes to user-facing i18n messages"],"tags":["speech-to-text","backend-error","http","response-parsing"],"backgroundTag":"api-success-false-response","analyzedSha":"711aa0550ee183ea495dc33e2c05c7943b70a60a","analyzedAt":"2026-08-28T07:56:06.558Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}