Budibase/budibase · error
Invalid custom REST template
Error message
Invalid custom REST template
What it means
createImportedRestConnection resolves import metadata for a REST template via getRestTemplateImportInfoRequest. That helper returns null for custom REST templates it cannot translate into a valid import request (e.g. an id that is not a known preset). When the request is null the function throws 'Invalid custom REST template' instead of calling the API with a malformed request.
Source
Thrown at packages/builder/src/settings/pages/connections/_components/createImportedRestConnection.ts:18
import type { RestTemplate, UIIntegration } from "@budibase/types"
import { API } from "@/api"
import { configFromIntegration } from "@/stores/selectors"
import { datasources } from "@/stores/builder/datasources"
import { getRestTemplateImportInfoRequest } from "@/helpers/restTemplates"
export const createImportedRestConnection = async ({
template,
integration,
projectIds,
}: {
template: RestTemplate
integration: UIIntegration
projectIds?: string[]
}) => {
const request = getRestTemplateImportInfoRequest(undefined, template.id)
if (!request) {
throw new Error("Invalid custom REST template")
}
const info = await API.getImportInfo(request)
const config = {
...configFromIntegration(integration),
url: info.servers?.[0]?.url ?? info.url ?? "",
authConfigs: [],
staticVariables: info.staticVariables || {},
defaultHeaders: {},
defaultQueryParameters: {},
rejectUnauthorized: true,
downloadImages: true,
}
return await datasources.create({
integration,
config,
name: template.name,View on GitHub (pinned to a81a902e9a)
Solutions
- Use one of the supported preset REST template ids (built-in templates) for this import path.
- For custom REST APIs, create the datasource directly with its URL/config instead of going through template import.
- Verify template.id is correct and corresponds to a template available in the current environment.
Example fix
// before
await createImportedRestConnection({ template: { id: "my-custom-api" }, integration })
// after
await API.createDatasource({ datasource: { datasourceType: "REST", name: "my-api", config: { url: "https://api.example.com" } } }) Defensive patterns
Strategy: validation
Validate before calling
const request = getRestTemplateImportInfoRequest(undefined, template.id)
if (!request) {
// route to manual REST datasource creation instead of throwing
return createManualRestDatasource(integration, template)
} Type guard
const isPresetTemplate = (t: RestTemplate): t is RestTemplate & { id: PresetRestTemplateId } =>
PRESET_REST_TEMPLATE_IDS.includes(t.id as PresetRestTemplateId) Try / catch
try {
return await createImportedRestConnection({ template, integration })
} catch (e) {
if (e.message === "Invalid custom REST template") {
return createManualRestDatasource(integration, template)
}
throw e
} Prevention
- Only pass built-in/preset template ids to template-based import helpers.
- Use direct datasource creation with explicit URL/config for custom REST APIs.
- Validate template.id against the current list of available templates before calling.
When it happens
Trigger: Calling createImportedRestConnection with a RestTemplate whose id is not a recognized preset template — e.g. a user-defined/custom REST template passed where the function expects a built-in template id, with no templateId derived from it.
Common situations: Passing a custom REST connection object instead of a preset template; template ids from older versions or other environments not recognized; automation/scripts replaying saved template configs whose ids no longer exist.
Related errors
- Source table '${relationship.sourceTable}' not found in data
- Target table '${relationship.targetTable}' not found in data
- automationId and appId are required
- Query ID or Revision is missing
- Failed to generate a unique name for the row action
AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29).
Data as JSON: /api/errors/a78483c2aaeda5b6.
Report an issue: GitHub.