{"record":{"id":"91519a649fa35bc0","repo":"Budibase/budibase","slug":"failed-to-load-curl-document","errorCode":null,"errorMessage":"Failed to load CURL document","messagePattern":"Failed to load CURL document","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/server/src/api/controllers/query/import/sources/curl.ts","lineNumber":65,"sourceCode":"/**\n * Curl\n * https://curl.se/docs/manpage.html\n */\nexport class Curl extends ImportSource {\n  curl: any\n\n  tryLoad = async (data: string): Promise<boolean> => {\n    try {\n      this.curl = parseCurl(data)\n    } catch (err) {\n      return false\n    }\n    return true\n  }\n\n  load = async (data: string): Promise<void> => {\n    if (!(await this.tryLoad(data))) {\n      throw new Error(\"Failed to load CURL document\")\n    }\n  }\n\n  getUrl = (): URL => {\n    return new URL(this.curl.raw_url)\n  }\n\n  getInfo = (): ImportInfo => {\n    const url = this.getUrl()\n    const method = this.curl.method\n    const path = url.pathname\n    return {\n      name: url.hostname,\n      url: url.origin,\n      securityHeaders: this.getSecurityHeaders(),\n      endpoints: [\n        {\n          id: this.buildEndpointId(method, path),","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/api/controllers/query/import/sources/curl.ts#L47-L83","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"// before\nconst data = \"https://api.example.com/items\" // not a curl command\nawait RestImporter.init(data)\n// after\nconst data = \"curl -X GET 'https://api.example.com/items'\"\nawait RestImporter.init(data)","handlingStrategy":"validation","validationCode":"const looksLikeCurl = (data: string) =>\n  /^\\s*curl\\b/.test(data.trim()) && /https?:\\/\\//.test(data)\nif (!looksLikeCurl(data) && !looksLikeOpenApi(data)) {\n  throw new Error(\"Input must be a curl command or an OpenAPI document\")\n}","typeGuard":"null","tryCatchPattern":"try {\n  await RestImporter.init(data)\n} catch (e) {\n  if (String(e?.message).includes(\"Failed to load CURL document\")) {\n    // ask user to paste a proper curl command (Copy as cURL)\n  }\n  throw e\n}","preventionTips":["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"],"tags":["curl","parsing","format"],"backgroundTag":"invalid-input-format","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}