{"record":{"id":"2ae56eaac74e63b5","repo":"n8n-io/n8n","slug":"uploadresponse-file-error-message-unknown-e","errorCode":null,"errorMessage":"${uploadResponse.file.error?.message ?? 'Unknown error'}","messagePattern":"\\$\\{uploadResponse\\.file\\.error\\?\\.message \\?\\? 'Unknown error'\\}","errorType":"exception","errorClass":"NodeOperationError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/vendors/GoogleGemini/helpers/utils.ts","lineNumber":110,"sourceCode":"\t\theaders: {\n\t\t\t'Content-Length': numBytes,\n\t\t\t'X-Goog-Upload-Offset': '0',\n\t\t\t'X-Goog-Upload-Command': 'upload, finalize',\n\t\t},\n\t\tbody: fileContent,\n\t})) as { file: File };\n\n\twhile (uploadResponse.file.state !== 'ACTIVE' && uploadResponse.file.state !== 'FAILED') {\n\t\tawait new Promise((resolve) => setTimeout(resolve, OPERATION_CHECK_INTERVAL));\n\t\tuploadResponse.file = (await apiRequest.call(\n\t\t\tthis,\n\t\t\t'GET',\n\t\t\t`/v1beta/${uploadResponse.file.name}`,\n\t\t)) as File;\n\t}\n\n\tif (uploadResponse.file.state === 'FAILED') {\n\t\tthrow new NodeOperationError(\n\t\t\tthis.getNode(),\n\t\t\tuploadResponse.file.error?.message ?? 'Unknown error',\n\t\t\t{\n\t\t\t\tdescription: 'Error uploading file',\n\t\t\t},\n\t\t);\n\t}\n\n\treturn { fileUri: uploadResponse.file.uri, mimeType: uploadResponse.file.mimeType };\n}\n\nasync function getFileStreamFromUrlOrBinary(\n\tthis: IExecuteFunctions,\n\ti: number,\n\tdownloadUrl?: string,\n\tfallbackMimeType?: string,\n\tqs?: IDataObject,\n): Promise<FileStreamData | FileBufferData> {","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/vendors/GoogleGemini/helpers/utils.ts#L92-L128","documentation":"Final failure branch of uploadFile (buffer-based upload to /upload/v1beta/files). The code polls the File resource until state is ACTIVE or FAILED; on FAILED it throws the API's error.message, defaulting to 'Unknown error' when the error object is absent. Description: 'Error uploading file'.","triggerScenarios":"Google's Files API accepted the bytes but the file ended in FAILED state: unsupported MIME type, file too large for the free tier, virus scan / safety rejection, malformed bytes, or a backend-side processing error.","commonSituations":"Uploading a format Gemini can't ingest (e.g. an obscure codec/container); a binary field that was empty or corrupted; transient Google backend failure during activation.","solutions":["Inspect the thrown message (response.error.message) — it usually names the rejected attribute (size/type).","Re-encode or re-export the file to a supported MIME type (PDF, MP3, WAV, PNG/JPEG/WebP, MP4 per the Gemini docs).","If transient, simply retry the upload (the node has no built-in retry here).","Confirm the binary isn't empty — check the upstream node produced a non-zero-length file."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"function isUploadableFile(buf: Buffer, mimeType: string): boolean {\n  const SUPPORTED = ['application/pdf','image/png','image/jpeg','image/webp','audio/mpeg','audio/wav','video/mp4'];\n  return buf.length > 0 && SUPPORTED.includes(mimeType);\n}","typeGuard":"interface GeminiFile { name: string; state: string; error?: { message: string } }\nfunction isFileFailed(f: GeminiFile): boolean {\n  return f.state === 'FAILED';\n}","tryCatchPattern":"for (let attempt = 1; attempt <= 3; attempt++) {\n  try { return await uploadFile(buf, mime); }\n  catch (e) {\n    if (attempt === 3 || /unsupported|too large/i.test(e.message)) throw e;\n    await new Promise(r => setTimeout(r, 1000 * attempt));\n  }\n}","preventionTips":["Pre-validate MIME type against Gemini's supported list before uploading.","Confirm the buffer is non-empty before calling uploadFile.","Treat a FAILED state as transient first — retry once — before assuming a format problem."],"tags":["google-gemini","file-upload","api-error","polling","binary","node-operation-error"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}