{"record":{"id":"e1810f2736b75485","repo":"janhq/jan","slug":"response-statustext","errorCode":null,"errorMessage":"response.statusText","messagePattern":"response\\.statusText","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"web-app/src/containers/ChatInput.tsx","lineNumber":1584,"sourceCode":"    if (textareaRef.current) textareaRef.current.focus()\n  }\n\n  const openAudioPicker = useCallback(async () => {\n    if (isPlatformTauri()) {\n      try {\n        const selected = await serviceHub.dialog().open({\n          multiple: true,\n          filters: [{ name: 'Audio', extensions: ['wav', 'mp3'] }],\n        })\n        if (selected) {\n          const paths = Array.isArray(selected) ? selected : [selected]\n          const files: File[] = []\n          for (const path of paths) {\n            try {\n              const { convertFileSrc } = await import('@tauri-apps/api/core')\n              const fileUrl = convertFileSrc(path)\n              const response = await fetch(fileUrl)\n              if (!response.ok) throw new Error(response.statusText)\n              const blob = await response.blob()\n              const fileName = path.split(/[\\\\/]/).filter(Boolean).pop() || 'audio'\n              const ext = fileName.toLowerCase().split('.').pop()\n              const mimeType = ext === 'mp3' ? 'audio/mpeg' : 'audio/wav'\n              files.push(new File([blob], fileName, { type: mimeType }))\n            } catch (error) {\n              console.error('Failed to read audio file:', error)\n              toast.error('Failed to read audio file', {\n                description: error instanceof Error ? error.message : String(error),\n              })\n            }\n          }\n          if (files.length > 0) await processAudioFiles(files)\n        }\n      } catch (error) {\n        console.error('Failed to open audio dialog:', error)\n      }\n      if (textareaRef.current) textareaRef.current.focus()","sourceCodeStart":1566,"sourceCodeEnd":1602,"githubUrl":"https://github.com/janhq/jan/blob/7205d770c1e097c3daf35a911176410e93bc5564/web-app/src/containers/ChatInput.tsx#L1566-L1602","documentation":"When importing dragged/dropped audio files via Tauri paths, the app converts the path to an asset URL and fetches it as a blob. A non-ok fetch response throws new Error(response.statusText), surfacing the HTTP failure text. The catch logs 'Failed to read audio file' and skips the file.","triggerScenarios":"fetch(convertFileSrc(path)) returns 4xx/5xx — e.g. the asset protocol is not allowed for that path, the file was deleted/moved after selection, or the path is outside the Tauri asset scope.","commonSituations":"Dropping files from directories not whitelisted in Tauri's asset protocol scope; files on network/removable drives that vanished; Tauri security config (assetProtocol enable/scope) missing; permission errors reading the file.","solutions":["Add the needed directories to tauri.conf.json assetProtocol.scope (e.g. {\"assetProtocol\":{\"enable\":true,\"scope\":[\"**\"]}}).","Verify the file still exists and is readable before fetching.","Check the browser console/network for the actual HTTP status to identify 403 vs 404.","Upgrade/verify @tauri-apps/api convertFileSrc usage matches the installed Tauri version."],"exampleFix":"// before\nconst response = await fetch(fileUrl)\nif (!response.ok) throw new Error(response.statusText)\n// after\nconst response = await fetch(fileUrl)\nif (!response.ok) {\n  throw new Error(`Failed to read audio file ${path}: ${response.status} ${response.statusText}`)\n}","handlingStrategy":"try-catch","validationCode":"const exists = await invoke('fs_exists', { path })\nif (!exists) throw new Error(`Audio file not found: ${path}`)","typeGuard":"const isOkResponse = (r: Response): r is Response & { ok: true } => r.ok","tryCatchPattern":"try {\n  const response = await fetch(convertFileSrc(path))\n  if (!response.ok) throw new Error(`${response.status} ${response.statusText}`)\n  const blob = await response.blob()\n  files.push(new File([blob], fileName, { type: mimeType }))\n} catch (error) {\n  console.error('Failed to read audio file:', path, error)\n  toast.error(`Could not read audio: ${path.split(/[\\\\/]/).pop()}`)\n}","preventionTips":["Configure assetProtocol enable/scope in tauri.conf.json to cover user file locations.","Check file existence before fetch when paths come from async sources.","Log response.status, not just statusText, for diagnosis.","Show per-file user feedback when an import is skipped."],"tags":["tauri","fetch","file-loading"],"backgroundTag":"http-error-response","analyzedSha":"7205d770c1e097c3daf35a911176410e93bc5564","analyzedAt":"2026-09-17T14:27:30.100Z","contentChangedAt":"2026-09-17T14:27:30.100Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}