Budibase/budibase · error
Tool name must be under 64 characters long
Error message
Tool name must be under 64 characters long
What it means
sanitiseToolName enforces LLM tool-name constraints: names must match ^[a-zA-Z0-9_-]+$ and be at most 64 characters. It sanitizes illegal characters to underscores but throws outright if the name exceeds 64 characters because truncation could collide or break mapping to the original tool.
Source
Thrown at packages/pro/src/ai/utils.ts:6
import { SupportedFileType } from "@budibase/types"
// tool names must align with regex "^[a-zA-Z0-9_-]+$"
export function sanitiseToolName(name: string) {
if (name.length > 64) {
throw new Error("Tool name must be under 64 characters long")
}
return name.replace(/[^a-zA-Z0-9_-]/g, "_")
}
export function normalizeContentType(contentType?: string): string {
if (!contentType) {
return "application/octet-stream"
}
// If it's already a proper MIME type, return it
if (contentType.includes("/")) {
return contentType
}
// Map SupportedFileType values to proper MIME types
const mimeTypeMap: Record<string, string> = {
[SupportedFileType.PDF]: "application/pdf",
[SupportedFileType.JPG]: "image/jpeg",View on GitHub (pinned to a81a902e9a)
Solutions
- Shorten the underlying resource name (table/query/datasource/automation) to keep the derived tool name under 64 chars.
- Truncate or hash the tool name before calling sanitiseToolName, keeping a mapping back to the full id.
- Add pre-validation in the UI/API that warns when a resource name will exceed the tool-name limit.
Example fix
// before
const name = sanitiseToolName(`table_${table.name}`) // may exceed 64
// after
const raw = `table_${table.name}`
const name = sanitiseToolName(raw.length > 64 ? `table_${raw.slice(6, 60)}_${hash(table.id)}` : raw) Defensive patterns
Strategy: validation
Validate before calling
if (`table_${name}`.length > 64) throw new Error(`Resource name "${name}" is too long for AI tool registration (max 64 incl. prefix)`) Type guard
function isValidToolName(name: string): boolean {
return name.length <= 64 && /^[a-zA-Z0-9_-]+$/.test(name.replace(/[^a-zA-Z0-9_-]/g, "_").slice(0, 64))
} Try / catch
try {
const tool = sanitiseToolName(rawName)
} catch (e) {
if (e.message.includes("under 64 characters")) {
const tool = sanitiseToolName(truncateWithHash(rawName, 64))
} else throw e
} Prevention
- Keep table/query/datasource names short, especially with prefixes
- Centralize tool-name derivation in one utility with length handling
- Validate resource names at creation time against the 64-char limit
When it happens
Trigger: Registering an AI tool whose derived name (e.g. from a table, datasource, query, or automation name) exceeds 64 characters — long resource names get concatenated into tool identifiers and blow the limit.
Common situations: Very long datasource/query names combined with prefixes like "query_" or "table_"; SCIM-synced or imported resources with long names; other providers (OpenAI/Anthropic) then reject the tool at the API level if the check were skipped.
Related errors
- Cannot create a query tool without a query ID
- Failed to generate a unique name for the row action
- AI message content must be a string
- Variable name has characters that are not allowed
- ${failureMessage}
AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29).
Data as JSON: /api/errors/86864a271fc4232a.
Report an issue: GitHub.