Budibase/budibase · error · HTTPError

Project package contains too many files.

Error message

Project package contains too many files.

What it means

To protect the server, imports enforce a file-count budget (MAX_PACKAGE_FILES) and total uncompressed size (MAX_EXTRACTED_SIZE_BYTES). readDirectoryRecursively increments totals per file and throws this 400 HTTPError as soon as the file count exceeds the cap (the next check throws for total size).

Solutions

  1. Remove unnecessary content (node_modules, build output, large assets) from the package and re-import
  2. Split very large apps into smaller imports where possible
  3. Check the package file count (tar -tf | wc -l) against the server's limit before importing
  4. If the limit is genuinely too small for your use case, raise MAX_PACKAGE_FILES in a self-hosted fork

Example fix

// before
tar -czf app.tar.gz app/        # includes app/node_modules (100k+ files)
// after
tar -czf app.tar.gz --exclude='node_modules' app/
Defensive patterns

Strategy: validation

Validate before calling

const { stdout } = await exec("tar -tzf pkg.tar.gz | wc -l")
if (Number(stdout) > MAX_PACKAGE_FILES) throw new Error(`Package has ${stdout} files; exceeds import limit`)

Type guard

null

Try / catch

try {
  await importProject(packagePath)
} catch (e) {
  if (e instanceof HTTPError && e.message.includes("too many files")) {
    // exclude bulky directories, repackage, retry
  } else throw e
}

Prevention

When it happens

Trigger: Importing a project package containing more files than MAX_PACKAGE_FILES — e.g. archives that include node_modules, build artifacts, datasets, or other bulk content alongside the actual project resources.

Common situations: Accidentally zipping dependency folders; exporting huge apps with many attachments/assets; denial-of-service style archives; automated pipelines bundling extra artifacts into the package.

Related errors


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

Appendix: source

Thrown at packages/server/src/sdk/workspace/projects/backups/imports.ts:207

    if (relPath.split(/[\\/]/).length > MAX_PATH_SEGMENTS) {
      throw new HTTPError(
        "Project package contains paths that are too deep.",
        400
      )
    }
    if (entry.isSymbolicLink()) {
      throw new HTTPError("Project package contains unsupported links.", 400)
    }
    if (entry.isDirectory()) {
      files.push(
        ...(await readDirectoryRecursively(fullPath, rootPath, totals))
      )
    } else {
      const stats = await fsp.stat(fullPath)
      totals.files += 1
      totals.bytes += stats.size
      if (totals.files > MAX_PACKAGE_FILES) {
        throw new HTTPError("Project package contains too many files.", 400)
      }
      if (totals.bytes > MAX_EXTRACTED_SIZE_BYTES) {
        throw new HTTPError("Project package is too large.", 400)
      }
      files.push(fullPath)
    }
  }

  return files
}

const validateProjectPackageBeforeExtraction = async (file: {
  path: string
}) => {
  const archiveHeader = new Uint8Array(2)
  const archiveFile = await fsp.open(file.path, "r")
  try {
    await archiveFile.read(archiveHeader, 0, archiveHeader.length, 0)

View on GitHub (pinned to a81a902e9a)