Budibase/budibase · error · HTTPError

Invalid import url

Error message

Invalid import url

What it means

parseImportUrl throws this HTTPError(400) when the URL string supplied for a query import cannot be parsed by the URL constructor.

Source

Thrown at packages/server/src/api/controllers/query/import/index.ts:79

    if (existingKey) {
      continue
    }
    target[headerName] = target[headerName] ?? ""
  }
}

const stringToHashKey = (input: string) =>
  crypto.createHash("sha512").update(JSON.stringify(input)).digest("hex")

const buildCacheKey = (input: ImporterInput) =>
  `openapiSpecs:${stringToHashKey(JSON.stringify("data" in input ? input.data : input.url))}`

function parseImportUrl(url: string): URL {
  let parsed: URL
  try {
    parsed = new URL(url)
  } catch {
    throw new HTTPError("Invalid import url", 400)
  }

  if (!ALLOWED_IMPORT_PROTOCOLS.has(parsed.protocol)) {
    throw new HTTPError("Only HTTP(S) URLs are allowed for query import", 400)
  }

  if (parsed.username || parsed.password) {
    throw new HTTPError("Import url must not contain credentials", 400)
  }

  return parsed
}

async function fetchFromUrl(url: string): Promise<string> {
  try {
    // validate protocol / credentials up front for clear 400 errors
    parseImportUrl(url)
    // fetchWithBlacklist resolves and validates the target, pins the request to

View on GitHub (pinned to a81a902e9a)

Solutions

  1. Provide a fully qualified absolute URL with http:// or https:// scheme
  2. Trim whitespace and stray quotes from the pasted URL
  3. Validate the URL client-side before submitting the import

Example fix

// before
const url = 'myapi.example.com/data.csv'
// after
const url = 'https://myapi.example.com/data.csv'
Defensive patterns

Strategy: validation

Validate before calling

let parsed: URL
try { parsed = new URL(url) } catch { throw new Error('Import source must be an absolute http(s) URL') }

Type guard

function isParsableUrl(url: string): boolean {
  try { new URL(url); return true } catch { return false }
}

Try / catch

try {
  await importSource(url)
} catch (err) {
  if (err instanceof HTTPError && err.message === 'Invalid import url') {
    // prompt user to correct the URL (400 Bad Request)
  }
}

Prevention

When it happens

Trigger: fetchFromUrl invoked from the query import endpoint with an empty, relative, or syntactically invalid URL (missing scheme, spaces, etc.).

Common situations: Users pasting CSV/API endpoints without the https:// prefix; form fields left blank; copy-paste introducing whitespace or smart quotes.

Related errors


AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29). Data as JSON: /api/errors/0d8ae1bf11d99115. Report an issue: GitHub.