{"record":{"id":"0d40c23350d53419","repo":"Budibase/budibase","slug":"no-response-found","errorCode":null,"errorMessage":"No response found","messagePattern":"No response found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/server/src/api/controllers/ai/budibaseai.ts","lineNumber":85,"sourceCode":"}\n\nexport async function chatCompletion(\n  ctx: Ctx<ChatCompletionRequest, ChatCompletionResponse>\n) {\n  if (env.SELF_HOSTED && !env.isDev()) {\n    ctx.throw(500, \"Budibase AI endpoints are not available in self-host\")\n  }\n\n  const { chat, providerOptions } =\n    await sdk.ai.llm.bbai.createBBAIClient(BBAI_DEFAULT_MODEL)\n  const result = await generateText({\n    model: chat,\n    ...sdk.ai.llm.toPrompt(ctx.request.body.messages),\n    providerOptions: providerOptions?.(false),\n  })\n\n  if (!result.text) {\n    throw new Error(\"No response found\")\n  }\n\n  const inputTokens =\n    result.usage?.inputTokens ?? result.totalUsage.inputTokens ?? 0\n  const outputTokens =\n    result.usage?.outputTokens ?? result.totalUsage.outputTokens ?? 0\n  const tokensUsed = calculateBudibaseAICredits(inputTokens, outputTokens)\n\n  ctx.body = {\n    messages: [\n      ...ctx.request.body.messages,\n      { role: \"assistant\", content: result.text },\n    ],\n    tokensUsed: tokensUsed || result.totalUsage.totalTokens || 0,\n  }\n}\n","sourceCodeStart":67,"sourceCodeEnd":102,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/api/controllers/ai/budibaseai.ts#L67-L102","documentation":"The legacy Budibase AI chatCompletion proxies the LLM call and expects a non-empty text result. When the provider returns a response without text (empty completion, filtered content, provider error swallowed by the SDK), the controller throws 'No response found'.","triggerScenarios":"POST chat completion via budibaseai.ts with messages that yield an empty result.text — e.g. all-content-filtered prompts, max_tokens too small, or provider outage returning empty text.","commonSituations":"Prompt triggers a content filter; provider returns empty completion; misconfigured provider/key silently returning blank responses; streaming disabled with an empty generation.","solutions":["Inspect the request messages/prompt for content that could be filtered or produce empty output","Verify the upstream provider credentials and model are valid and the provider is healthy","Add retry logic with backoff for transient empty responses","Migrate to the v2 endpoint (budibaseai-v2.ts) which has richer error handling"],"exampleFix":"// before\nconst result = await callLlm({ messages })\nuseText(result.text)\n// after\ntry {\n  const result = await callLlm({ messages })\n  if (!result.text) throw new Error(\"No response found\")\n  useText(result.text)\n} catch (e) {\n  // retry or surface a friendly message\n}","handlingStrategy":"try-catch","validationCode":"if (!Array.isArray(messages) || messages.length === 0) {\n  throw new Error(\"messages required before calling chat completion\")\n}","typeGuard":"const hasText = (r: { text?: unknown }): r is { text: string } =>\n  typeof r.text === \"string\" && r.text.length > 0","tryCatchPattern":"try {\n  const res = await chatCompletion(body)\n} catch (e) {\n  if (String(e.message).includes(\"No response found\")) {\n    // retry with backoff or fall back to another provider\n  }\n}","preventionTips":["Add client-side retry with backoff for empty LLM responses","Log the raw provider response to diagnose empty outputs","Avoid prompts likely to trip content filters"],"tags":["ai","llm","empty-response"],"backgroundTag":"empty-llm-response","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}