Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

🔧 fix: handle known OpenAI errors with empty intermediate reply (#5562)

James Lamine85c6a706c396
diff --git a/api/app/clients/OpenAIClient.js b/api/app/clients/OpenAIClient.js
index 76b0bdf8dc..8329a8b148 100644
--- a/api/app/clients/OpenAIClient.js
+++ b/api/app/clients/OpenAIClient.js
@@ -1464,7 +1464,11 @@ ${convo}
(err instanceof OpenAI.OpenAIError && err?.message?.includes('missing finish_reason'))
) {
logger.error('[OpenAIClient] Known OpenAI error:', err);
- return intermediateReply.join('');
+ if (intermediateReply.length > 0) {
+ return intermediateReply.join('');
+ } else {
+ throw err;
+ }
} else if (err instanceof OpenAI.APIError) {
if (intermediateReply.length > 0) {
return intermediateReply.join('');