{"record":{"id":"0bd46c6887920ea9","repo":"FlowiseAI/Flowise","slug":"error-0bd46c","errorCode":null,"errorMessage":"${error}","messagePattern":"\\$\\{error\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/agents/OpenAIAssistant/OpenAIAssistant.ts","lineNumber":940,"sourceCode":"                }\n            }\n\n            let llmOutput = returnVal.replace(imageRegex, '')\n            llmOutput = llmOutput.replace('<br/>', '')\n\n            await analyticHandlers.onLLMEnd(llmIds, llmOutput)\n            await analyticHandlers.onChainEnd(parentIds, messageData, true)\n\n            return {\n                text: returnVal,\n                usedTools,\n                artifacts,\n                fileAnnotations,\n                assistant: { assistantId: openAIAssistantId, threadId, runId: runThreadId, messages: messageData }\n            }\n        } catch (error) {\n            await analyticHandlers.onChainError(parentIds, error, true)\n            throw new Error(error)\n        }\n    }\n}\n\nconst downloadImg = async (\n    openai: OpenAI,\n    fileId: string,\n    fileName: string,\n    orgId: string,\n    ...paths: string[]\n): Promise<{ filePath: string; totalSize: number }> => {\n    const response = await openai.files.content(fileId)\n\n    // Extract the binary data from the Response object\n    const image_data = await response.arrayBuffer()\n\n    // Convert the binary data to a Buffer\n    const image_data_buffer = Buffer.from(image_data)","sourceCodeStart":922,"sourceCodeEnd":958,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/agents/OpenAIAssistant/OpenAIAssistant.ts#L922-L958","documentation":"The outer catch-all of OpenAIAssistant agent's run. Any exception not handled by the inner tool/thread handlers is reported via onChainError then re-thrown as `new Error(error)` — stringifying the original (often an OpenAI SDK error) and losing its type, status, and stack. This is the same anti-pattern as errors 20/25/28.","triggerScenarios":"Any uncaught failure during assistant execution: assistant retrieval, message listing, streaming setup, file annotation handling, downloadImg, or an error that escapes the inner try blocks.","commonSituations":"OpenAI SDK throws a 401/429/5xx not caught inner; message-list pagination fails; a file annotation references a missing file; streaming setup error.","solutions":["Check server logs and analytics (onChainError fires with the original error reference).","Identify the OpenAI status: 401 → key; 429 → rate limit/quota; 5xx → provider; 404 → wrong assistant/thread id.","Fix the specific upstream/credential/config issue.","Patch to `throw new Error(error instanceof Error ? error.message : String(error), { cause: error })`."],"exampleFix":"// before\n        } catch (error) {\n            await analyticHandlers.onChainError(parentIds, error, true)\n            throw new Error(error)\n        }\n// after\n        } catch (error) {\n            const message = error instanceof Error ? error.message : String(error)\n            await analyticHandlers.onChainError(parentIds, error, true)\n            throw new Error(message, { cause: error })\n        }","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await assistantNode.run(nodeData, input, options)\n} catch (e) {\n  // original error stringified; use onChainError analytics + logs for the cause\n  const msg = (e as Error).message\n  if (/401|Unauthorized/.test(msg)) fixKey()\n  else if (/429|rate/i.test(msg)) backoff()\n  throw e\n}","preventionTips":["Subscribe to onChainError analytics to capture the original error object.","Keep server logging verbose in non-prod to see the un-stringified cause.","Validate assistant, credential, and thread ids before runtime.","Patch the catch to preserve `cause` so callers can branch."],"tags":["agent","openai-assistant","error-wrapping","stack-trace-loss","catch-all"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}