{"record":{"id":"19de70f2e4fc27e6","repo":"n8n-io/n8n","slug":"file-error-message-unknown-error","errorCode":null,"errorMessage":"${file.error?.message ?? 'Unknown error'}","messagePattern":"\\$\\{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":242,"sourceCode":"\tif ('buffer' in fileData) {\n\t\treturn await uploadFile.call(this, fileData.buffer, fileData.mimeType);\n\t}\n\n\tconst { stream, mimeType } = fileData;\n\tconst uploadResponse = (await uploadStream.call(this, stream, {\n\t\tendpoint: '/upload/v1beta/files',\n\t\tmimeType,\n\t})) as { body: { file: File } };\n\n\tlet file = uploadResponse.body.file;\n\n\twhile (file.state !== 'ACTIVE' && file.state !== 'FAILED') {\n\t\tawait new Promise((resolve) => setTimeout(resolve, OPERATION_CHECK_INTERVAL));\n\t\tfile = (await apiRequest.call(this, 'GET', `/v1beta/${file.name}`)) as File;\n\t}\n\n\tif (file.state === 'FAILED') {\n\t\tthrow new NodeOperationError(this.getNode(), file.error?.message ?? 'Unknown error', {\n\t\t\tdescription: 'Error uploading file',\n\t\t});\n\t}\n\n\treturn { fileUri: file.uri, mimeType: file.mimeType };\n}\n\nexport async function createFileSearchStore(this: IExecuteFunctions, displayName: string) {\n\treturn (await apiRequest.call(this, 'POST', '/v1beta/fileSearchStores', {\n\t\tbody: { displayName },\n\t})) as IDataObject;\n}\n\nexport async function uploadToFileSearchStore(\n\tthis: IExecuteFunctions,\n\ti: number,\n\tfileSearchStoreName: string,\n\tdisplayName: string,","sourceCodeStart":224,"sourceCodeEnd":260,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/vendors/GoogleGemini/helpers/utils.ts#L224-L260","documentation":"Streamed-upload counterpart of [848]. In transferFile, after uploadStream finishes and the code polls the File until ACTIVE/FAILED, a FAILED state throws file.error?.message ?? 'Unknown error' with description 'Error uploading file'. Same semantic as the buffer path but reached via the streaming transferFile helper.","triggerScenarios":"transferFile is used (URL or binary-as-stream source) and Google reports the uploaded file's state as FAILED — same causes as [848]: unsupported type, too large, safety rejection, or backend error.","commonSituations":"Downloading a remote file (HTTP Request → URL) and piping it straight to Gemini where the format is rejected; streaming a large media file that exceeds tier limits.","solutions":["Read file.error.message — it carries Google's reason for the FAILED state.","Re-encode the source to a supported MIME; reduce size; retry on transient errors.","If downloading from a URL, first fetch and validate the content-type matches a Gemini-supported type before transferFile."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"function isSupportedForUpload(contentType: string | undefined): boolean {\n  const SUPPORTED = ['application/pdf','image/png','image/jpeg','image/webp','audio/mpeg','audio/wav','video/mp4'];\n  return !!contentType && SUPPORTED.includes(contentType.split(';')[0]);\n}","typeGuard":"function isStreamableUploadFailure(file: { state: string; error?: { message: string } }): boolean {\n  return file.state === 'FAILED';\n}","tryCatchPattern":"for (let attempt = 1; attempt <= 3; attempt++) {\n  try { return await transferFile(i, url, 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":["When transferring from a URL, fetch and check the content-type before piping to Gemini.","Keep source files within Gemini's documented size limits.","Retry once on FAILED — it can be transient."],"tags":["google-gemini","file-upload","streaming","api-error","polling","node-operation-error"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}