Budibase/budibase · error · BadRequestError

Attempted to upload a file without a filename

Error message

Attempted to upload a file without a filename

What it means

Thrown by uploadFile when an uploaded part has no resolvable filename (getUploadFilename returns falsy). Every stored file needs a name to compute its key/extension.

Source

Thrown at packages/server/src/api/controllers/static/index.ts:264

}

export const uploadFile = async function (
  ctx: Ctx<void, ProcessAttachmentResponse>
) {
  const file = ctx.request?.files?.file
  if (!file) {
    throw new BadRequestError("No file provided")
  }

  let files = file && Array.isArray(file) ? Array.from(file) : [file]

  ctx.body = await Promise.all(
    files.map(async file => {
      const fileName = getUploadFilename(file)
      const filePath = getUploadPath(file)
      const rawMimeType = getUploadMimeType(file)
      if (!fileName) {
        throw new BadRequestError(
          "Attempted to upload a file without a filename"
        )
      }
      if (!filePath) {
        throw new BadRequestError("Attempted to upload a file without a path")
      }

      const extension = [...fileName.split(".")].pop()
      if (!extension) {
        throw new BadRequestError(
          `File "${fileName}" has no extension, an extension is required to upload a file`
        )
      }

      const extensionLower = extension.toLowerCase()
      const isPublicUser =
        ctx.roleId === roles.BUILTIN_ROLE_IDS.PUBLIC ||
        ctx.user?.roleId === roles.BUILTIN_ROLE_IDS.PUBLIC

View on GitHub (pinned to a81a902e9a)

Solutions

  1. Provide a filename when appending: fd.append('file', blob, 'photo.png')
  2. Use curl's @path syntax so a filename is included
  3. Fix server-side multipart parsing if it strips filenames

Example fix

// before
fd.append('file', new Blob([data]))
// after
fd.append('file', new Blob([data]), 'report.pdf')
Defensive patterns

Strategy: validation

Validate before calling

function uploadHasFilename(file) {
  return Boolean(file && file.name && file.name.length > 0)
}

Type guard

const hasFilename = (f: unknown): f is { name: string } =>
  typeof f === 'object' && f !== null && typeof (f as any).name === 'string' && (f as any).name.length > 0

Try / catch

try {
  await api.uploadFile(fd)
} catch (err) {
  if (err instanceof BadRequestError && err.message.includes('without a filename')) {
    // re-append the blob with an explicit filename
  } else throw err
}

Prevention

When it happens

Trigger: Uploading a file part with an empty filename, a Blob created without a filename in FormData, or a client sending a part without a filename attribute in Content-Disposition.

Common situations: JavaScript clients appending a raw Blob (no third argument), curl -F without @filename, or programmatic multipart construction omitting the filename.

Related errors


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