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 valueView on GitHub (pinned to a81a902e9a)
Solutions
- Validate the name on the client (trim + non-empty) before calling create/update
- 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
- Check form state binding so an unfilled input is blocked at submit time
- 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
- Trim and validate names in the UI before submit
- Never send empty strings for untouched fields
- Block form submission until a name is provided
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
- Agent with name '${name}' already exists.
- agentId is required
- _id and _rev are required
- Invalid bookmark query
- Invalid limit query
AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29).
Data as JSON: /api/errors/b4cb7024ec10671f.
Report an issue: GitHub.