{"record":{"id":"fe68a00f78f60cb9","repo":"Budibase/budibase","slug":"template-description-is-required","errorCode":null,"errorMessage":"Template description is required","messagePattern":"Template description is required","errorType":"http","errorClass":"HTTPError","httpStatus":400,"severity":"error","filePath":"packages/server/src/api/controllers/restTemplate.ts","lineNumber":75,"sourceCode":") => {\n  const file = ctx.request.files?.file\n  if (!file || Array.isArray(file)) {\n    throw new HTTPError(\"Exactly one OpenAPI template file is required\", 400)\n  }\n\n  const uploadDetails = getUploadDetails(file)\n  if (!uploadDetails) {\n    throw new HTTPError(\"Invalid OpenAPI template upload\", 400)\n  }\n\n  try {\n    const name = ctx.request.body.name\n    const description = ctx.request.body.description\n    if (typeof name !== \"string\" || !name.trim()) {\n      throw new HTTPError(\"Template name is required\", 400)\n    }\n    if (typeof description !== \"string\") {\n      throw new HTTPError(\"Template description is required\", 400)\n    }\n\n    const fileExtension = getFileExtension(uploadDetails.filename)\n    const data = await readFile(uploadDetails.filepath, \"utf8\")\n    let importer\n    let info\n    try {\n      importer = await createImporter({ data })\n      const source = importer.getSource().getImportSource()\n      if (source !== \"openapi2.0\" && source !== \"openapi3.0\") {\n        throw new Error(\"Unsupported OpenAPI source\")\n      }\n      info = importer.getInfo()\n    } catch {\n      throw new HTTPError(\"File must contain a valid OpenAPI schema\", 400)\n    }\n\n    ctx.body = {","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/api/controllers/restTemplate.ts#L57-L93","documentation":"This 400 HTTPError is thrown by the REST template upload controller when the multipart request's 'description' body field is missing or not a string. Description is required metadata stored alongside the uploaded OpenAPI template.","triggerScenarios":"POSTing to the custom REST template upload endpoint with a valid file and name but no 'description' field, or a description sent as a non-string value (null, number, object).","commonSituations":"Scripts that send only name + file; form UIs without a description field; clients forwarding JSON bodies where description is undefined.","solutions":["Add a string 'description' text field to the multipart form body","Ensure description is a plain string (empty string is accepted; only non-strings are rejected)","Retry the upload"],"exampleFix":"// before\nformData.append(\"name\", \"My API Template\") // description missing\n// after\nformData.append(\"name\", \"My API Template\")\nformData.append(\"description\", \"Petstore OpenAPI spec\")","handlingStrategy":"validation","validationCode":"const description = body.description\nif (typeof description !== \"string\") {\n  throw new Error(\"Template description must be a string before upload\")\n}","typeGuard":"const isString = (v: unknown): v is string => typeof v === \"string\"","tryCatchPattern":"try {\n  await uploadTemplate(form)\n} catch (e) {\n  if (e?.status === 400 && e?.message === \"Template description is required\") {\n    // mark description field as required in the form\n  } else throw e\n}","preventionTips":["Include a description input in the upload form and mark it required","Default description to \"\" (empty string is accepted) rather than omitting it","Verify the multipart form contains all three parts: name, description, file"],"tags":["validation","http-400","rest-template","input-validation"],"backgroundTag":"missing-required-field","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}