Budibase/budibase · error

File cannot be imported

Error message

File cannot be imported

What it means

decryptFiles walks an extracted import directory and decrypts .enc files via zlib-based operations; the raw zlib failure "incorrect header check" (wrong password/corrupt data) is caught and re-thrown as the friendlier "File cannot be imported". It signals the package is not decryptable with what was supplied.

Source

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

      for (let file of await fsp.readdir(dirPath)) {
        const inputPath = join(dirPath, file)
        if (!inputPath.endsWith(ATTACHMENT_DIRECTORY)) {
          const stats = await fsp.lstat(inputPath)
          if (stats.isFile() && inputPath.endsWith(".enc")) {
            const outputPath = inputPath.replace(/\.enc$/, "")
            await encryption.decryptFile(inputPath, outputPath, password)
            await fsp.rm(inputPath)
          } else if (stats.isDirectory()) {
            await processDirectory(inputPath)
          }
        }
      }
    }

    await processDirectory(path)
  } catch (err: any) {
    if (err.message === "incorrect header check") {
      throw new Error("File cannot be imported")
    }
    throw err
  }
}

export function getGlobalDBFile(tmpPath: string) {
  return fs.readFileSync(join(tmpPath, GLOBAL_DB_EXPORT_FILE), "utf8")
}

export function getListOfAppsInMulti(tmpPath: string) {
  return fs.readdirSync(tmpPath).filter(dir => dir !== GLOBAL_DB_EXPORT_FILE)
}

export interface ImportAppOpts {
  updateAttachmentColumns?: boolean
  importObjStoreContents?: boolean
  objectStoreAppId?: string
  preserveLiteLLMConfig?: boolean

View on GitHub (pinned to a81a902e9a)

Solutions

  1. Re-export the app and provide the exact password used at export time (template.file.password)
  2. Verify the uploaded file is complete — compare file size/hash against the original export
  3. Confirm you are importing the correct archive type through the correct endpoint
  4. Test decryption locally (e.g. openssl/zlib) to confirm the password before calling the API

Example fix

// before
await importApp({ file: { path: p, type: "text/plain", password: "wrongpass" } })
// after
await importApp({ file: { path: p, type: "text/plain", password: process.env.EXPORT_PASSWORD } })
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-check: attempt local zlib header read
execSync(`head -c 2 ${archivePath} | xxd | grep -q 789c || echo 'bad zlib header'`)

Try / catch

try {
  await importApp(template)
} catch (err: any) {
  if (err.message === "File cannot be imported") {
    // prompt for the correct password or obtain a clean export
  } else {
    throw err
  }
}

Prevention

When it happens

Trigger: importApp/extractProjectPackage called on an encrypted export while passing the wrong password (or none in a path that reaches decryption), so zlib inflate fails with "incorrect header check" which is mapped to this error.

Common situations: Importing an app export encrypted with a password the importer does not have; truncated/corrupted upload where the first bytes are no longer the zlib header; importing an unencrypted archive through the encrypted-import code path.

Related errors


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