Budibase/budibase · error · Error
Failed to load CURL document
Error message
Failed to load CURL document
What it means
Curl.tryLoad attempts to parse the pasted data as a curl command (extracting the URL, method, headers, body). If parsing fails, load throws 'Failed to load CURL document', meaning the input is not a recognizable curl invocation.
Source
Thrown at packages/server/src/api/controllers/query/import/sources/curl.ts:65
/**
* Curl
* https://curl.se/docs/manpage.html
*/
export class Curl extends ImportSource {
curl: any
tryLoad = async (data: string): Promise<boolean> => {
try {
this.curl = parseCurl(data)
} catch (err) {
return false
}
return true
}
load = async (data: string): Promise<void> => {
if (!(await this.tryLoad(data))) {
throw new Error("Failed to load CURL document")
}
}
getUrl = (): URL => {
return new URL(this.curl.raw_url)
}
getInfo = (): ImportInfo => {
const url = this.getUrl()
const method = this.curl.method
const path = url.pathname
return {
name: url.hostname,
url: url.origin,
securityHeaders: this.getSecurityHeaders(),
endpoints: [
{
id: this.buildEndpointId(method, path),View on GitHub (pinned to a81a902e9a)
Solutions
- Paste a genuine curl command starting with 'curl', e.g. curl -X GET 'https://api.example.com/items' -H 'Authorization: Bearer x'
- Re-copy the command using devtools 'Copy as cURL (bash)' and avoid smart quotes/line continuations that break parsing
- Simplify the command to its essential flags (method, URL, headers, -d body) if exotic flags are used
- If the input is actually an OpenAPI spec, import it with the openapi type instead
Example fix
// before const data = "https://api.example.com/items" // not a curl command await RestImporter.init(data) // after const data = "curl -X GET 'https://api.example.com/items'" await RestImporter.init(data)
Defensive patterns
Strategy: validation
Validate before calling
const looksLikeCurl = (data: string) =>
/^\s*curl\b/.test(data.trim()) && /https?:\/\//.test(data)
if (!looksLikeCurl(data) && !looksLikeOpenApi(data)) {
throw new Error("Input must be a curl command or an OpenAPI document")
} Type guard
null
Try / catch
try {
await RestImporter.init(data)
} catch (e) {
if (String(e?.message).includes("Failed to load CURL document")) {
// ask user to paste a proper curl command (Copy as cURL)
}
throw e
} Prevention
- Copy curl commands via browser devtools 'Copy as cURL (bash)', not 'Copy as fetch'
- Avoid smart quotes and shell-specific continuations when pasting
- Strip exotic flags the parser may not handle; keep -X, URL, -H, -d
- Don't paste bare URLs or PowerShell/wget commands as curl
When it happens
Trigger: Auto-detected import (no type) falling through to the Curl source with data that is a raw URL, an HTTP request snippet, or a curl command using flags the parser does not understand (e.g. --data-urlencode, multi-line with unusual quoting, Windows caret continuations).
Common situations: Users paste a URL alone expecting it to import; pasted curl copied from browser devtools with 'Copy as fetch' instead of 'Copy as cURL'; PowerShell's Invoke-WebRequest or wget syntax pasted as if it were curl; curly quotes from a rich-text editor breaking tokenization.
Related errors
- Unable to determine delimiter
- Unsupported import data
- Unsupported method: ${method}
- Invalid filter ${type}: ${token}
- Failed to parse response body: ${err}
AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29).
Data as JSON: /api/errors/91519a649fa35bc0.
Report an issue: GitHub.