Budibase/budibase · error · Error

File id not found

Error message

File id not found

What it means

Thrown during LiteLLM file upload when the /v1/files response JSON parses successfully but has no string `id` field. Budibase needs the LiteLLM file id to reference the uploaded file in subsequent chat calls, so an unexpected response shape is rejected with this error.

Source

Thrown at packages/server/src/sdk/workspace/ai/llm/bbai.ts:258

        formdata.append("file", fileBlob, filename)
        formdata.append("model", model)

        const liteLLMBaseUrl = environment.LITELLM_URL.replace(/\/v1\/?$/, "")
        const response = await fetch(`${liteLLMBaseUrl}/v1/files`, {
          method: "POST",
          headers: {
            Authorization: `Bearer ${getBBAIKey()}`,
          },
          body: formdata,
        })

        if (!response.ok) {
          throw await HTTPError.fromResponse(response)
        }

        const result = await response.json()
        if (typeof result.id !== "string") {
          throw new Error("File id not found")
        }
        return unwrapLiteLLMFileId(result.id)
      } else {
        const fileBuffer = Buffer.from(await fileBlob.arrayBuffer())
        const base64 = fileBuffer.toString("base64")

        if (isImage) {
          return `data:${type};base64,${base64}`
        }
        if (!env.BUDICLOUD_URL) {
          throw new Error("No Budibase URL found")
        }
        const licenseKey = await licensing.keys.getLicenseKey()
        if (!licenseKey) {
          throw new Error("No license key found")
        }

        const response = await fetch(

View on GitHub (pinned to a81a902e9a)

Solutions

  1. Log/inspect the full LiteLLM /v1/files response body to see the actual payload
  2. Upgrade LiteLLM to a version with OpenAI-compatible file upload support
  3. Verify LITELLM_URL points at the LiteLLM proxy root, not a provider directly
  4. Check LiteLLM proxy logs for upstream provider errors swallowed during upload

Example fix

// before: blind cast
const result = await response.json()
return result.id
// after: guard the shape
const result = await response.json()
if (typeof result.id !== "string") {
  throw new Error(`Unexpected LiteLLM file upload response: ${JSON.stringify(result)}`)
}
Defensive patterns

Strategy: type-guard

Validate before calling

const res = await fetch(`${litellmUrl}/v1/files`, init)
const body = await res.json()
if (typeof body?.id !== "string") {
  throw new Error(`LiteLLM upload returned unexpected payload`)
}

Type guard

function hasFileId(x: unknown): x is { id: string } {
  return typeof x === "object" && x !== null && typeof (x as { id?: unknown }).id === "string"
}

Try / catch

try {
  const id = await bbaiClient.uploadFile(blob, type)
} catch (e) {
  if (e.message === "File id not found") {
    log.error("LiteLLM file upload returned malformed response — check LiteLLM version/proxy")
  }
  throw e
}

Prevention

When it happens

Trigger: Uploading a file via createBBAIClient's LiteLLM path when LiteLLM returns an error payload (e.g. a JSON error body with HTTP 200, or a proxy returning HTML/JSON without id), or a LiteLLM version whose files API response schema differs.

Common situations: LiteLLM behind a misconfigured proxy that intercepts file uploads; LiteLLM deployed at an older version without OpenAI-compatible /v1/files support; provider upstream rejecting the file but LiteLLM not propagating the failure status.

Related errors


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