Budibase/budibase · error · HTTPError

Template name is required

Error message

Template name is required

What it means

This 400 HTTPError is thrown by the REST template upload controller when the multipart request's 'name' body field is missing, not a string, or an empty/whitespace-only string. The controller validates name before parsing the uploaded OpenAPI file, since name and description are stored as the template's metadata.

Source

Thrown at packages/server/src/api/controllers/restTemplate.ts:72

    UploadCustomRestTemplateRequest,
    UploadCustomRestTemplateResponse
  >
) => {
  const file = ctx.request.files?.file
  if (!file || Array.isArray(file)) {
    throw new HTTPError("Exactly one OpenAPI template file is required", 400)
  }

  const uploadDetails = getUploadDetails(file)
  if (!uploadDetails) {
    throw new HTTPError("Invalid OpenAPI template upload", 400)
  }

  try {
    const name = ctx.request.body.name
    const description = ctx.request.body.description
    if (typeof name !== "string" || !name.trim()) {
      throw new HTTPError("Template name is required", 400)
    }
    if (typeof description !== "string") {
      throw new HTTPError("Template description is required", 400)
    }

    const fileExtension = getFileExtension(uploadDetails.filename)
    const data = await readFile(uploadDetails.filepath, "utf8")
    let importer
    let info
    try {
      importer = await createImporter({ data })
      const source = importer.getSource().getImportSource()
      if (source !== "openapi2.0" && source !== "openapi3.0") {
        throw new Error("Unsupported OpenAPI source")
      }
      info = importer.getInfo()
    } catch {
      throw new HTTPError("File must contain a valid OpenAPI schema", 400)

View on GitHub (pinned to a81a902e9a)

Solutions

  1. Add a non-empty 'name' text field to the multipart form body alongside the file
  2. Ensure the field is sent as a string (not a file part or null) and trim it to confirm it is non-empty
  3. Retry the upload with corrected form data

Example fix

// before
formData.append("file", fileBlob) // name missing
// after
formData.append("name", "My API Template")
formData.append("description", "Petstore API")
formData.append("file", fileBlob)
Defensive patterns

Strategy: validation

Validate before calling

const name = body.name
if (typeof name !== "string" || !name.trim()) {
  throw new Error("Template name is required before upload")
}

Type guard

const isNonEmptyString = (v: unknown): v is string =>
  typeof v === "string" && v.trim().length > 0

Try / catch

try {
  await uploadTemplate(form)
} catch (e) {
  if (e?.status === 400 && e?.message === "Template name is required") {
    // surface name field as invalid in the UI
  } else throw e
}

Prevention

When it happens

Trigger: POSTing to the custom REST template upload endpoint with multipart form data containing a file but no 'name' field, a name sent as a non-string value, or a name of only whitespace (e.g. name=' ').

Common situations: Client scripts that only attach the file part of the multipart form; API wrappers that forget to forward text fields alongside the file; frontend forms where the name input was left blank or trimmed to empty.

Understand the failure class

Background: "Missing required field" and "field is required" errors: why libraries reject payloads that omit mandatory fields — this error's family across 20 libraries.

Related errors


AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29). Data as JSON: /api/errors/a0d57cec72407e7c. Report an issue: GitHub.