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: Surface Document Extraction Failures (#15651)

aeyeopsdeve504128e8d89
diff --git a/api/server/services/Files/process.js b/api/server/services/Files/process.js
index 09c0b0dc57..c4fac9bf63 100644
--- a/api/server/services/Files/process.js
+++ b/api/server/services/Files/process.js
@@ -889,6 +889,7 @@ const processAgentFileUpload = async ({ req, res, metadata, sseStream }) => {
`[processAgentFileUpload] Document parser failed for ${extractionFileLabel}:`,
errorMetadata,
);
+ throw err;
}
};
diff --git a/api/server/services/Files/process.spec.js b/api/server/services/Files/process.spec.js
index 20562fa627..90f46f47c3 100644
--- a/api/server/services/Files/process.spec.js
+++ b/api/server/services/Files/process.spec.js
@@ -622,7 +622,7 @@ describe('processAgentFileUpload', () => {
await expect(
processAgentFileUpload({ req, res: mockRes, metadata: makeMetadata() }),
- ).rejects.toThrow(/image-based and requires an OCR service/);
+ ).rejects.toThrow('No text found in document');
expect(parseText).not.toHaveBeenCalled();
});
@@ -632,8 +632,11 @@ describe('processAgentFileUpload', () => {
handleFileUpload: jest.fn().mockRejectedValue(new Error('PRIVATE parser failure')),
});
extractInspectableFileText.mockImplementationOnce(async ({ extract }) => {
- await extract();
- throw makeUninspectableExtractedTextError();
+ try {
+ await extract();
+ } catch {
+ throw makeUninspectableExtractedTextError();
+ }
});
const req = makeReq({
mimetype: PDF_MIME,
@@ -771,7 +774,7 @@ describe('processAgentFileUpload', () => {
await expect(
processAgentFileUpload({ req, res: mockRes, metadata: makeMetadata() }),
- ).rejects.toThrow(/image-based and requires an OCR service/);
+ ).rejects.toThrow('failure');
expect(parseText).not.toHaveBeenCalled();
});
@@ -862,8 +865,11 @@ describe('processAgentFileUpload', () => {
handleFileUpload: jest.fn().mockRejectedValue(new Error('PRIVATE parser failure')),
});
extractInspectableFileText.mockImplementationOnce(async ({ extract }) => {
- await extract();
- throw makeUninspectableExtractedTextError();
+ try {
+ await extract();
+ } catch {
+ throw makeUninspectableExtractedTextError();
+ }
});
const req = makeReq({
mimetype: DOCX_MIME,
diff --git a/packages/api/src/utils/files.ts b/packages/api/src/utils/files.ts
index d3e192675b..b313dc9b6f 100644
--- a/packages/api/src/utils/files.ts
+++ b/packages/api/src/utils/files.ts
@@ -7,6 +7,12 @@ const USER_FACING_UPLOAD_ERRORS = [
['Invalid file format', 'Invalid file format'],
['exceeds token limit', 'File content exceeds token limit'],
['Unable to extract text from', 'Unable to extract text from file'],
+ ['No text found in document', 'No text found in document'],
+ ['MB document parser limit', 'File exceeds the document parser size limit'],
+ ['MB per-entry decompressed cap', 'Document entry exceeds the decompressed size limit'],
+ ['total decompressed size exceeds the', 'Document exceeds the total decompressed size limit'],
+ ['MB decompressed limit', 'Document exceeds the decompressed size limit'],
+ ['MB storage limit', 'Extracted text exceeds the storage size limit'],
] as const;
const ASCII_FILENAME_SAFE_PATTERN = /^[a-zA-Z0-9._-]$/;