{"record":{"id":"2d3815d0764a6cc1","repo":"Budibase/budibase","slug":"config-name-is-required","errorCode":null,"errorMessage":"Config name is required","messagePattern":"Config name is required","errorType":"http","errorClass":"HTTPError","httpStatus":400,"severity":"error","filePath":"packages/server/src/api/controllers/ai/configs.ts","lineNumber":85,"sourceCode":"  }\n  ctx.body = result\n}\n\nexport const fetchAIProviders = async (\n  ctx: UserCtx<void, LLMProvidersResponse>\n) => {\n  const allProviders = await sdk.ai.configs.fetchLiteLLMProviders()\n  const providers = allProviders.filter(p => p.id !== BUDIBASE_AI_PROVIDER_ID)\n  ctx.body = providers\n}\n\nexport const createAIConfig = async (\n  ctx: UserCtx<CreateAIConfigRequest, AIConfigResponse>\n) => {\n  const body = ctx.request.body\n\n  if (!body.name) {\n    throw new HTTPError(\"Config name is required\", 400)\n  }\n\n  const createRequest: RequiredKeys<\n    Parameters<typeof sdk.ai.configs.create>[0]\n  > = {\n    name: body.name,\n    provider: body.provider,\n    credentialsFields: body.credentialsFields,\n    model: body.model,\n\n    webSearchConfig: body.webSearchConfig,\n    configType: body.configType,\n    reasoningEffort: body.reasoningEffort,\n    isDefault: body.isDefault,\n  }\n\n  const newConfig = await sdk.ai.configs.create(createRequest)\n","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/api/controllers/ai/configs.ts#L67-L103","documentation":"createAIConfig requires a name on the request body before delegating to sdk.ai.configs.create. An empty/undefined name fails this guard and the endpoint returns 400 'Config name is required'.","triggerScenarios":"POST /api/ai/configs with a JSON body missing the name field, name set to \"\" or null, or Content-Type not application/json so the body parses without name.","commonSituations":"Scripted/API clients forgetting the field; form UI not binding the name input; sending multipart or wrong content type so ctx.request.body is empty.","solutions":["Include a non-empty name field in the POST body.","Send the request with Content-Type: application/json so the body is parsed.","In UI integrations, validate the name input is non-empty before submitting.","If calling programmatically, spread the config object and confirm name survives (no key renaming)."],"exampleFix":"// before\nawait api.post(\"/api/ai/configs\", { provider: \"litellm-main\", credentialsFields: {} })\n// after\nawait api.post(\"/api/ai/configs\", { name: \"My GPT Config\", provider: \"litellm-main\", credentialsFields: {} })","handlingStrategy":"validation","validationCode":"if (typeof config.name !== \"string\" || !config.name.trim()) {\n  throw new Error(\"AI config name is required before calling create\")\n}","typeGuard":"const hasName = (b: { name?: string }): b is { name: string } =>\n  typeof b.name === \"string\" && b.name.trim().length > 0","tryCatchPattern":"try {\n  await api.post(\"/api/ai/configs\", config)\n} catch (e) {\n  if (e.status === 400 && e.message === \"Config name is required\") {\n    // prompt user for a name / fix payload and retry once\n  }\n}","preventionTips":["Require name in client-side forms (required attribute + validation)","Send JSON with Content-Type: application/json","Type create payloads with name: string (non-optional)","Sanity-check the serialized body in devtools when a 400 names a missing field"],"tags":["http-400","validation","ai-configs","missing-field"],"backgroundTag":"missing-required-field","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}