{"record":{"id":"0f8690b5cdd1bf77","repo":"Budibase/budibase","slug":"error-generating-tables","errorCode":null,"errorMessage":"Error generating tables","messagePattern":"Error generating tables","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/frontend-core/src/api/ai.ts","lineNumber":121,"sourceCode":"            if (done) {\n              break\n            }\n            buffer += decoder.decode(value, { stream: true })\n\n            let boundary = buffer.indexOf(SSE_EVENT_DELIMITER)\n            while (boundary !== -1) {\n              const eventChunk = buffer.slice(0, boundary)\n              buffer = buffer.slice(boundary + SSE_EVENT_DELIMITER.length)\n\n              const event = parseSSEEventChunk(eventChunk)\n              if (event?.type === \"progress\" && onProgress) {\n                onProgress(event.message)\n              }\n              if (event?.type === \"result\") {\n                finalResponse = { createdTables: event.createdTables || [] }\n              }\n              if (event?.type === \"error\") {\n                throw new Error(event.message || \"Error generating tables\")\n              }\n\n              boundary = buffer.indexOf(SSE_EVENT_DELIMITER)\n            }\n          }\n\n          if (!finalResponse) {\n            throw new Error(\"No result received from table generation stream\")\n          }\n\n          return finalResponse\n        } catch (error: any) {\n          throw new Error(error?.message || \"Error generating tables\")\n        }\n      },\n    })\n  },\n","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/frontend-core/src/api/ai.ts#L103-L139","documentation":"While parsing the SSE stream from /api/ai/tables, an event with type \"error\" arrives from the server-side AI generation. The client surfaces the server-provided event.message, falling back to the generic \"Error generating tables\" when the message is empty. This is the transport for backend failures (e.g. LLM errors) during streaming.","triggerScenarios":"Server-side table generation fails after the stream has opened and it emits {type:\"error\"} — e.g. LLM provider error, invalid prompt, backend exception — and the client rethrows it in the parseResponse handler.","commonSituations":"LLM provider outage or rate limiting, invalid model config on the Budibase instance, prompt content rejected by the provider, license/quota exhaustion on the AI backend.","solutions":["Read the actual error message (event.message) in the thrown Error to identify the server-side cause.","Check the backend/pro logs for the underlying LLM failure and verify the AI model is configured and licensed.","Retry the request if the failure was transient (provider 429/5xx).","Adjust the prompt or table requirements if the message indicates a content/policy rejection."],"exampleFix":"// before\ncatch (e) { console.log(e) }\n// after\ncatch (e) {\n  toast.error(`Table generation failed: ${e.message}`)\n  // inspect server logs for the LLM provider error\n}","handlingStrategy":"retry","validationCode":"// ensure backend reachable and model configured before calling\nconst health = await fetch(\"/api/ai/health\").then(r => r.ok)","typeGuard":"function isAIStreamErrorEvent(ev: unknown): ev is { type: \"error\"; message: string } {\n  return typeof ev === \"object\" && ev !== null && (ev as any).type === \"error\"\n}","tryCatchPattern":"try {\n  return await generateTables(req)\n} catch (e) {\n  if (isTransient(e.message)) return generateTables(req) // retry once\n  showError(e.message)\n}","preventionTips":["Verify LLM provider keys and quotas before heavy generation runs","Log the event.message from SSE error events for diagnosis","Apply rate limiting/backoff for AI requests"],"tags":["ai","sse","streaming","llm"],"backgroundTag":"llm-generation-failed","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}