Budibase/budibase · error · HTTPError

Agent name is required.

Error message

Agent name is required.

What it means

guardName is the shared validation used by agent create and update. It first requires a non-empty (after trim) name, throwing HTTPError(NAME_REQUIRED_ERROR, 400) if the name is blank. Names are then checked for duplicates against existing agents using normalized comparison.

Source

Thrown at packages/server/src/sdk/workspace/ai/agents/crud.ts:101

const DEFAULT_OPERATION_NAME = "Main operation"
const LEGACY_QUERY_TOOL_REPLACEMENTS_CACHE_TTL_SECONDS = 60

const fetchRaw = async (): Promise<DeprecatedAgent[]> => {
  const db = context.getWorkspaceDB()
  const result = await db.allDocs<DeprecatedAgent>(
    docIds.getDocParams(DocumentType.AGENT, undefined, {
      include_docs: true,
    })
  )

  return result.rows
    .map(row => row.doc)
    .filter((doc): doc is DeprecatedAgent => !!doc)
}

const guardName = async (name: string, id?: string) => {
  if (!name.trim()) {
    throw new HTTPError(NAME_REQUIRED_ERROR, 400)
  }

  const agents = await fetchRaw()
  const normalizedName = helpers.normalizeForComparison(name)
  const duplicate = agents.find(
    agent =>
      helpers.normalizeForComparison(agent.name) === normalizedName &&
      agent._id !== id
  )

  if (duplicate) {
    throw new HTTPError(`Agent with name '${name}' already exists.`, 400)
  }
}

const encodeSecret = (value?: string): string | undefined => {
  if (!value || value.startsWith(SECRET_ENCODING_PREFIX)) {
    return value

View on GitHub (pinned to a81a902e9a)

Solutions

  1. Validate the name on the client (trim + non-empty) before calling create/update
  2. Send a meaningful name in the request body; do not pass name: "" for partial updates — omit fields you don't intend to change only if the endpoint supports it, otherwise supply the existing name
  3. Check form state binding so an unfilled input is blocked at submit time
  4. Catch the 400 HTTPError in callers and surface a friendly 'name required' message

Example fix

// before
await sdk.ai.agents.update({ _id, _rev, name: "" })
// after
const name = newName.trim()
if (!name) throw new Error("Provide an agent name")
await sdk.ai.agents.update({ _id, _rev, name })
Defensive patterns

Strategy: validation

Validate before calling

if (typeof name !== "string" || !name.trim()) {
  throw new Error("Agent name is required")
}

Try / catch

try {
  await sdk.ai.agents.create({ name })
} catch (err) {
  if (err instanceof HTTPError && err.status === 400) {
    // surface 'name required' to the user / fix the payload
  } else { throw err }
}

Prevention

When it happens

Trigger: POST/PUT to the agent CRUD API with name = "", " ", undefined coerced to empty, or a body where name is present but whitespace only; programmatic sdk.ai.agents.create/update calls that omit or blank the name field.

Common situations: Builder form submitting before the name input is filled; API clients sending partial update bodies with name: ""; trimming inconsistencies where the UI shows a name but raw value is spaces; copy-paste of whitespace-only names.

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/b4cb7024ec10671f. Report an issue: GitHub.