{"record":{"id":"8a5f6723c6d6bf38","repo":"FlowiseAI/Flowise","slug":"http-error-status-response-status","errorCode":null,"errorMessage":"HTTP error! status: ${response.status}","messagePattern":"HTTP error! status: (.+?)","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/agents/OpenAIAssistant/OpenAIAssistant.ts","lineNumber":980,"sourceCode":"\n    return { filePath: path, totalSize }\n}\n\nconst downloadFile = async (\n    openAIApiKey: string,\n    fileObj: any,\n    fileName: string,\n    orgId: string,\n    ...paths: string[]\n): Promise<{ path: string; totalSize: number }> => {\n    try {\n        const response = await fetch(`https://api.openai.com/v1/files/${fileObj.id}/content`, {\n            method: 'GET',\n            headers: { Accept: '*/*', Authorization: `Bearer ${openAIApiKey}` }\n        })\n\n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`)\n        }\n\n        // Extract the binary data from the Response object\n        const data = await response.arrayBuffer()\n\n        // Convert the binary data to a Buffer\n        const data_buffer = Buffer.from(data)\n        const mime = 'application/octet-stream'\n\n        const { path, totalSize } = await addSingleFileToStorage(mime, data_buffer, fileName, orgId, ...paths)\n\n        return { path, totalSize }\n    } catch (error) {\n        console.error('Error downloading or writing the file:', error)\n        return { path: '', totalSize: 0 }\n    }\n}\n","sourceCodeStart":962,"sourceCodeEnd":998,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/agents/OpenAIAssistant/OpenAIAssistant.ts#L962-L998","documentation":"downloadImgFromOpenAI uses fetch to GET `https://api.openai.com/v1/files/<id>/content`. If `response.ok` is false (non-2xx), it throws `HTTP error! status: <code>`. The status is the OpenAI Files API response code; the response body (with the reason) is not read before throwing.","triggerScenarios":"The file id no longer exists (404), the API key lacks access (401/403), rate limited (429), or OpenAI returns 5xx. Also triggered if the key is invalid.","commonSituations":"A file annotation references a file that was deleted from OpenAI; the assistant's key differs from the one with file access; quota exhausted; transient OpenAI outage.","solutions":["Map the status: 404 → file deleted/missing; 401/403 → key/permission; 429 → quota; 5xx → retry.","Verify the file id is correct and still present under the account.","Ensure the OpenAI key used has Files read scope.","For 5xx/429, retry with backoff.","Patch to read the body for the reason: `const detail = await response.text(); throw new Error(\\`HTTP ${response.status}: ${detail}\\`)`."],"exampleFix":"// before\n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`)\n        }\n// after\n        if (!response.ok) {\n            const detail = await response.text().catch(() => '')\n            throw new Error(`OpenAI Files API HTTP ${response.status}: ${detail || response.statusText}`)\n        }","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"async function fetchFileWithRetry(id: string, key: string, attempts = 3) {\n  for (let i = 0; i < attempts; i++) {\n    try {\n      return await downloadImgFromOpenAI(/*...*/)\n    } catch (e) {\n      const status = /status: (\\d+)/.exec((e as Error).message)?.[1]\n      if (status && Number(status) >= 500 && i < attempts - 1) {\n        await new Promise((r) => setTimeout(r, 1000 * 2 ** i)); continue\n      }\n      throw e\n    }\n  }\n}","preventionTips":["Verify file ids still exist before downloading annotations.","Ensure the OpenAI key has Files read scope.","Retry 5xx/429 with exponential backoff.","Cache downloaded files to avoid repeated fetches."],"tags":["agent","openai-assistant","file-download","http","network"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}