Budibase/budibase · error · Error
Invalid file input – source and file type do not match
Error message
Invalid file input – source and file type do not match
What it means
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.
Source
Thrown at packages/server/src/automations/steps/ai/extract.ts:268
} catch {
return value
}
}
const file =
inputs.source === DocumentSourceType.URL
? inputs.file
: tryParse(inputs.file)
if (inputs.source === DocumentSourceType.URL && typeof file === "string") {
extractInput = await processUrlFile(file, inputs.fileType, llm)
} else if (
inputs.source === DocumentSourceType.ATTACHMENT &&
typeof file !== "string"
) {
extractInput = await processAttachmentFile(file, llm)
} else {
throw new Error("Invalid file input – source and file type do not match")
}
const output = getOutputFromSchema(inputs.schema)
const modelMessages = buildExtractModelMessages(extractInput)
const providerOptions = llm.providerOptions?.(false)
const response = await generateText({
model: llm.chat,
messages: modelMessages,
providerOptions,
output,
experimental_download: downloadAssetsForExtract,
})
if (!response.output || response.output.data == null) {
throw new Error("Could not parse AI response as valid JSON.")
}
const data = response.output.data
if (!data.length) {View on GitHub (pinned to a81a902e9a)
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
Example fix
// before
{ "source": "ATTACHMENT", "file": "https://example.com/a.pdf" } // string with ATTACHMENT source
// after
{ "source": "URL", "file": "https://example.com/a.pdf" } Defensive patterns
Strategy: validation
Validate before calling
const isUrlSource = inputs.source === DocumentSourceType.URL && typeof file === "string"
const isAttachment = inputs.source === DocumentSourceType.ATTACHMENT && typeof file === "object" && file !== null
if (!isUrlSource && !isAttachment) {
throw new Error("source and file input types do not match")
} Type guard
function sourceMatchesInput(inputs: { source: DocumentSourceType }, file: unknown): boolean {
return (inputs.source === DocumentSourceType.URL && typeof file === "string") ||
(inputs.source === DocumentSourceType.ATTACHMENT && typeof file === "object" && file !== null)
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- AI message content must be a string
- Tool name must be under 64 characters long
- Cannot create a query tool without a query ID
- Unsupported BBAI model: ${model}
- AI user message must be a string
AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29).
Data as JSON: /api/errors/cc1b844732e9dc6f.
Report an issue: GitHub.