{"record":{"id":"c4fb5b83ae07df1b","repo":"Budibase/budibase","slug":"we-didn-t-understand-your-prompt-this-can-happen","errorCode":null,"errorMessage":"We didn't understand your prompt. This can happen if the prompt isn't specific, or if it's a request for something other than code. Try expressing your request in a different way.","messagePattern":"We didn't understand your prompt\\. This can happen if the prompt isn't specific, or if it's a request for something other than code\\. Try expressing your request in a different way\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/builder/src/components/common/CodeEditor/AIGen.svelte","lineNumber":45,"sourceCode":"  const thresholdExpansionWidth = 350\n\n  $: shouldAlwaysBeExpanded =\n    expandedOnly ||\n    (parentWidth !== null && parentWidth > thresholdExpansionWidth)\n\n  $: expanded = shouldAlwaysBeExpanded || expanded\n\n  async function generateJs(prompt: string) {\n    promptText = \"\"\n    if (!prompt.trim()) return\n\n    previousContents = value\n    promptText = prompt\n    try {\n      const resp = await API.generateJs({ prompt, bindings })\n      const code = resp.code\n      if (code === \"\") {\n        throw new Error(\n          \"We didn't understand your prompt. This can happen if the prompt isn't specific, or if it's a request for something other than code. Try expressing your request in a different way.\"\n        )\n      }\n      suggestedCode = code\n      dispatch(\"update\", { code })\n    } catch (e: any) {\n      console.error(e)\n\n      if (\"code\" in e && e.code === APIWarningCode.USAGE_LIMIT_EXCEEDED) {\n        notifications.error(\n          \"Monthly usage limit reached. We're exploring options to expand this soon. Questions? Contact support@budibase.com\"\n        )\n      } else if (\"message\" in e) {\n        notifications.error(`Unable to generate code: ${e.message}`)\n      } else {\n        notifications.error(`Unable to generate code.`)\n      }\n    }","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/builder/src/components/common/CodeEditor/AIGen.svelte#L27-L63","documentation":"AIGen.svelte sends the user's prompt to the AI code-generation API (API.generateJs). If the service responds successfully but returns an empty code string — meaning the model couldn't produce code from the prompt — the component throws this descriptive error telling the user to rephrase. The catch block then surfaces it as a notification.","triggerScenarios":"Submitting an AI prompt in the builder code editor where the backend returns code === \"\": vague prompts, prompts not related to code generation, prompts the safety/model layer refuses, or bindings/prompt combinations the model can't satisfy.","commonSituations":"Asking conversational questions (\"what does this do?\") instead of requesting code; overly short or ambiguous prompts like \"sort it\"; prompts in non-English phrasing the model misreads; transient model degradation returning empty output.","solutions":["Rewrite the prompt to explicitly describe the code you want, including inputs and expected output","Add context — mention the variable/bindings to use and the framework (plain JS in a Budibase binding)","Break the request into a smaller, single-purpose code generation task","Retry once in case the empty response was transient; if persistent, the prompt content is the issue"],"exampleFix":"// before (prompt)\n\"make it work\"\n// after (prompt)\n\"Write a JavaScript function that takes the binding data.items and returns them sorted by the 'name' property alphabetically\"","handlingStrategy":"validation","validationCode":"if (!prompt || prompt.trim().length < 10) {\n  throw new Error(\"Prompt too vague for AI code generation\")\n}","typeGuard":"null","tryCatchPattern":"try {\n  const resp = await API.generateJs({ prompt, bindings })\n  if (!resp.code) throw new Error(\"AI returned no code — rephrase the prompt\")\n} catch (e) {\n  notify.error(e.message)\n}","preventionTips":["Write specific prompts describing inputs, outputs and behavior","Include the relevant bindings/variables in the prompt","Request one focused piece of code per prompt","Retry once on empty responses before changing the prompt"],"tags":["ai","validation","prompt","builder"],"backgroundTag":"empty-ai-response","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}