{"record":{"id":"b87a49e13970e984","repo":"Budibase/budibase","slug":"could-not-extract-the-requested-data","errorCode":null,"errorMessage":"Could not extract the requested data.","messagePattern":"Could not extract the requested data\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"packages/server/src/automations/steps/ai/extract.ts","lineNumber":287,"sourceCode":"    }\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) {\n      throw new Error(\"Could not extract the requested data.\")\n    }\n\n    return {\n      data,\n      success: true,\n    }\n  } catch (err: any) {\n    console.error(\"Document extraction error:\", err)\n    return {\n      success: false,\n      data: {},\n      response: automationUtils.getError(err),\n    }\n  }\n}\n\nfunction createZodSchemaFromRecord(schema: Record<string, any>) {\n  const zodFields: Record<string, z.ZodType<any>> = {}","sourceCodeStart":269,"sourceCodeEnd":305,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/automations/steps/ai/extract.ts#L269-L305","documentation":"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.","triggerScenarios":"response.output.data exists but has length 0 — the LLM returned valid JSON with an empty result set after processing the supplied document.","commonSituations":"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.","solutions":["Verify the supplied document actually contains the data being requested","Adjust the prompt/schema to match the document's actual field names/content","Use text-based documents rather than scanned images, or enable OCR upstream","Loosen the schema/prompt so the model can return partial matches"],"exampleFix":"// before\nprompt: \"Extract invoice_number\" // document has no invoice number → []\n// after\nprompt: \"Extract invoice_number if present, otherwise null\" with schema allowing null","handlingStrategy":"try-catch","validationCode":"// before running, check the document contains the target content\nif (!documentText.includes(\"invoice\")) {\n  throw new Error(\"Document does not appear to contain the data to extract\")\n}","typeGuard":null,"tryCatchPattern":"try {\n  const result = await extractStep.run(inputs, ctx)\n} catch (err) {\n  if (err.message === \"Could not extract the requested data.\") {\n    // treat as no-match; adjust schema/prompt or notify user\n  }\n  throw err\n}","preventionTips":["Verify documents contain the requested fields","Avoid scanned/image PDFs without OCR","Allow nullable fields in the schema so partial extractions succeed","Iterate on prompts with sample documents before deploying"],"tags":["ai","llm","empty-result","extraction"],"backgroundTag":"llm-empty-extraction-result","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}