{"record":{"id":"cc1b844732e9dc6f","repo":"Budibase/budibase","slug":"invalid-file-input-source-and-file-type-do-not-m","errorCode":null,"errorMessage":"Invalid file input – source and file type do not match","messagePattern":"Invalid file input – source and file type do not match","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/server/src/automations/steps/ai/extract.ts","lineNumber":268,"sourceCode":"      } catch {\n        return value\n      }\n    }\n\n    const file =\n      inputs.source === DocumentSourceType.URL\n        ? inputs.file\n        : tryParse(inputs.file)\n\n    if (inputs.source === DocumentSourceType.URL && typeof file === \"string\") {\n      extractInput = await processUrlFile(file, inputs.fileType, llm)\n    } else if (\n      inputs.source === DocumentSourceType.ATTACHMENT &&\n      typeof file !== \"string\"\n    ) {\n      extractInput = await processAttachmentFile(file, llm)\n    } else {\n      throw new Error(\"Invalid file input – source and file type do not match\")\n    }\n\n    const output = getOutputFromSchema(inputs.schema)\n    const modelMessages = buildExtractModelMessages(extractInput)\n    const providerOptions = llm.providerOptions?.(false)\n    const response = await generateText({\n      model: llm.chat,\n      messages: modelMessages,\n      providerOptions,\n      output,\n      experimental_download: downloadAssetsForExtract,\n    })\n    if (!response.output || response.output.data == null) {\n      throw new Error(\"Could not parse AI response as valid JSON.\")\n    }\n    const data = response.output.data\n\n    if (!data.length) {","sourceCodeStart":250,"sourceCodeEnd":286,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/automations/steps/ai/extract.ts#L250-L286","documentation":"run() in the AI extract step dispatches on inputs.source: URL source expects a string URL, ATTACHMENT source expects a file object. If neither branch matches — source and the actual shape of file disagree — it throws this mismatch error.","triggerScenarios":"inputs.source is set to a value inconsistent with the file input: e.g. source=ATTACHMENT while file is a string URL, or an unrecognized source value whose branch falls into the else, at automation execution time.","commonSituations":"Hand-edited or exported/imported automation definitions where source and file fields were changed independently; API-triggered automations passing mismatched payloads; builder version differences altering the step schema.","solutions":["Open the extract step in the builder and re-select the file source so source and file input match","If source is URL/ATTACHMENT, ensure the file field is the correct type (string URL vs file object)","Re-create the step if the definition was hand-edited and is inconsistent","Validate the automation JSON: source must correspond to the file field's runtime type"],"exampleFix":"// before\n{ \"source\": \"ATTACHMENT\", \"file\": \"https://example.com/a.pdf\" } // string with ATTACHMENT source\n// after\n{ \"source\": \"URL\", \"file\": \"https://example.com/a.pdf\" }","handlingStrategy":"validation","validationCode":"const isUrlSource = inputs.source === DocumentSourceType.URL && typeof file === \"string\"\nconst isAttachment = inputs.source === DocumentSourceType.ATTACHMENT && typeof file === \"object\" && file !== null\nif (!isUrlSource && !isAttachment) {\n  throw new Error(\"source and file input types do not match\")\n}","typeGuard":"function sourceMatchesInput(inputs: { source: DocumentSourceType }, file: unknown): boolean {\n  return (inputs.source === DocumentSourceType.URL && typeof file === \"string\") ||\n    (inputs.source === DocumentSourceType.ATTACHMENT && typeof file === \"object\" && file !== null)\n}","tryCatchPattern":null,"preventionTips":["Configure source and file fields together in the builder","Validate imported/hand-edited automation definitions","Don't change the file field type without updating source"],"tags":["validation","ai","automation","input-mismatch"],"backgroundTag":"input-validation-failed","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}