{"record":{"id":"91f1be280e0c5667","repo":"Mintplex-Labs/anything-llm","slug":"error-downloading-model-response-statustext","errorCode":null,"errorMessage":"Error downloading model: ${response.statusText}","messagePattern":"Error downloading model: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"frontend/src/models/utils/dmrUtils.js","lineNumber":27,"sourceCode":"   * @param {(percentage: number) => void} progressCallback - The callback to receive the progress percentage. If the model is already downloaded, it will be called once with 100.\n   * @returns {Promise<{success: boolean, error: string|null}>}\n   */\n  downloadModel: async function (\n    modelId,\n    basePath = \"\",\n    progressCallback = () => {}\n  ) {\n    // eslint-disable-next-line no-async-promise-executor\n    return new Promise(async (resolve) => {\n      try {\n        const response = await fetch(`${API_BASE}/utils/dmr/download-model`, {\n          method: \"POST\",\n          headers: baseHeaders(),\n          body: JSON.stringify({ modelId, basePath }),\n        });\n\n        if (!response.ok)\n          throw new Error(\"Error downloading model: \" + response.statusText);\n        const reader = response.body.getReader();\n        let done = false;\n\n        while (!done) {\n          const { value, done: readerDone } = await reader.read();\n          if (readerDone) {\n            done = true;\n            resolve({ success: true });\n          } else {\n            const chunk = new TextDecoder(\"utf-8\").decode(value);\n            const lines = chunk.split(\"\\n\");\n            for (const line of lines) {\n              if (line.startsWith(\"data:\")) {\n                const data = safeJsonParse(line.slice(5));\n                switch (data?.type) {\n                  case \"success\":\n                    done = true;\n                    resolve({ success: true });","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/frontend/src/models/utils/dmrUtils.js#L9-L45","documentation":"Thrown by DmrUtils.downloadModel when POST /utils/dmr/download-model returns non-2xx before the streaming reader is attached. The endpoint streams Server-Sent-Events (data: lines with progress/success/error payloads). The thrown message concatenates response.statusText, so the underlying reason depends on the server's reason phrase. The outer Promise executor catches and resolves { success: false, error }.","triggerScenarios":"The DMR (Device Model Registry) backend is unavailable, modelId is unknown to the registry, basePath points to a non-writable directory, or the user is not authorized to download models.","commonSituations":"modelId copied from a different DMR version that no longer exists; basePath on a read-only mount; backend DMR service crashed or never started; disk full so the backend rejects before streaming; HTTP/2 response with empty statusText yields the bare 'Error downloading model: ' prefix.","solutions":["Read the Network tab response body for /utils/dmr/download-model — statusText is often unhelpful.","Verify modelId exists in the DMR catalog via the model-list endpoint before invoking downloadModel.","Confirm basePath is writable by the backend process and has sufficient free space.","Improve the thrown message to include res.status and the response body for diagnosis."],"exampleFix":"// before\nif (!response.ok)\n  throw new Error(\"Error downloading model: \" + response.statusText);\n\n// after\nif (!response.ok) {\n  const body = await response.text().catch(() => \"\");\n  throw new Error(`Error downloading model (HTTP ${response.status}): ${body.slice(0, 200)}`);\n}","handlingStrategy":"try-catch","validationCode":"// Verify modelId is in the catalog and basePath is writable-shaped before download.\nasync function modelExistsInCatalog(modelId) {\n  const r = await fetch(`${API_BASE}/utils/dmr/models`, { headers: baseHeaders() });\n  if (!r.ok) return false;\n  const list = await r.json();\n  return Array.isArray(list) && list.some(m => m.id === modelId);\n}","typeGuard":"function isDownloadResult(x): x is { success: boolean; error?: string } {\n  return x && typeof x.success === 'boolean';\n}","tryCatchPattern":"const { success, error } = await DmrUtils.downloadModel(modelId, basePath, onProgress);\nif (!success) {\n  showDownloadError(error || 'Download failed.');\n  return;\n}","preventionTips":["Inspect the actual HTTP status/body in DevTools rather than relying on statusText.","Verify free disk space on basePath before downloading large models.","Pre-check modelId existence in the DMR catalog to fail fast with a clear reason."],"tags":["frontend","api-client","model-download","dmr","streaming","network"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}