{"record":{"id":"0185046c2fe4cb78","repo":"discourse/discourse","slug":"download-failed-response-status","errorCode":null,"errorMessage":"Download failed: ${response.status}","messagePattern":"Download failed: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"frontend/discourse/app/lib/download-blob.js","lineNumber":54,"sourceCode":"  }\n  a.rel = \"noopener\";\n  document.body.appendChild(a);\n  a.click();\n  document.body.removeChild(a);\n  setTimeout(() => URL.revokeObjectURL(objectUrl), REVOKE_AFTER);\n}\n\n// Fetches `url` and triggers a browser download of the response body.\nexport default async function downloadBlob(\n  url,\n  { fallbackFilename, fetchOptions } = {}\n) {\n  const response = await fetch(url, {\n    credentials: \"same-origin\",\n    ...fetchOptions,\n  });\n  if (!response.ok) {\n    throw new Error(`Download failed: ${response.status}`);\n  }\n  triggerBlobDownload(await response.blob(), {\n    fallbackFilename,\n    contentDisposition: response.headers.get(\"Content-Disposition\"),\n  });\n}\n","sourceCodeStart":36,"sourceCodeEnd":61,"githubUrl":"https://github.com/discourse/discourse/blob/1b2d7253e854205d2c95c80b2c6a1cdd42e45059/frontend/discourse/app/lib/download-blob.js#L36-L61","documentation":"downloadBlob fetched the URL with same-origin credentials and got a non-ok HTTP response; instead of a blob, it throws with the numeric status. Callers like theme export and download flows use this to surface server-side failures (auth, not-found, server errors) rather than getting an empty or error-page file.","triggerScenarios":"Thrown at frontend/discourse/app/lib/download-blob.js:54 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the status code: 401/403 means authentication or permission issues, 404 means the URL is wrong, 5xx is a server error","Verify the user is logged in and authorized for the resource","Retry the request if the status indicates a transient server error"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"1b2d7253e854205d2c95c80b2c6a1cdd42e45059","analyzedAt":"2026-08-26T03:11:08.302Z","contentChangedAt":"2026-08-26T03:11:08.302Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}