Budibase/budibase · warning · Error

Could not extract the requested data.

Error message

Could not extract the requested data.

What it means

When the AI response parsed successfully as JSON but the resulting data array is empty, run() throws this error: the model extracted nothing matching the requested schema from the document.

Source

Thrown at packages/server/src/automations/steps/ai/extract.ts:287

    }

    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) {
      throw new Error("Could not extract the requested data.")
    }

    return {
      data,
      success: true,
    }
  } catch (err: any) {
    console.error("Document extraction error:", err)
    return {
      success: false,
      data: {},
      response: automationUtils.getError(err),
    }
  }
}

function createZodSchemaFromRecord(schema: Record<string, any>) {
  const zodFields: Record<string, z.ZodType<any>> = {}

View on GitHub (pinned to a81a902e9a)

Solutions

  1. Verify the supplied document actually contains the data being requested
  2. Adjust the prompt/schema to match the document's actual field names/content
  3. Use text-based documents rather than scanned images, or enable OCR upstream
  4. Loosen the schema/prompt so the model can return partial matches

Example fix

// before
prompt: "Extract invoice_number" // document has no invoice number → []
// after
prompt: "Extract invoice_number if present, otherwise null" with schema allowing null
Defensive patterns

Strategy: try-catch

Validate before calling

// before running, check the document contains the target content
if (!documentText.includes("invoice")) {
  throw new Error("Document does not appear to contain the data to extract")
}

Try / catch

try {
  const result = await extractStep.run(inputs, ctx)
} catch (err) {
  if (err.message === "Could not extract the requested data.") {
    // treat as no-match; adjust schema/prompt or notify user
  }
  throw err
}

Prevention

When it happens

Trigger: response.output.data exists but has length 0 — the LLM returned valid JSON with an empty result set after processing the supplied document.

Common situations: Document doesn't contain the fields being extracted; prompt/schema asking for the wrong keys; wrong file attached; scanned/image PDFs with no extractable text; overly strict schema causing the model to return nothing rather than partial data.

Related errors


AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29). Data as JSON: /api/errors/b87a49e13970e984. Report an issue: GitHub.