{"record":{"id":"d7ee231239df39d0","repo":"Budibase/budibase","slug":"workspace-exports-cannot-be-imported-as-project-pa","errorCode":null,"errorMessage":"Workspace exports cannot be imported as Project packages.","messagePattern":"Workspace exports cannot be imported as Project packages\\.","errorType":"validation","errorClass":"HTTPError","httpStatus":400,"severity":"error","filePath":"packages/server/src/sdk/workspace/projects/backups/imports.ts","lineNumber":944,"sourceCode":"  try {\n    if (encryptPassword) {\n      try {\n        await decryptFiles(tmpPath, encryptPassword)\n      } catch {\n        throw new HTTPError(\"Project package could not be decrypted.\", 400)\n      }\n    }\n\n    const packageFiles = await readDirectoryRecursively(tmpPath)\n    const rootEntries = await fsp.readdir(tmpPath)\n    if (rootEntries.some(entry => entry.endsWith(\".enc\")) && !encryptPassword) {\n      throw new HTTPError(\n        \"Files are encrypted but no password has been supplied.\",\n        400\n      )\n    }\n    if (rootEntries.includes(\"db.txt\")) {\n      throw new HTTPError(\n        \"Workspace exports cannot be imported as Project packages.\",\n        400\n      )\n    }\n    if (\n      rootEntries.some(\n        entry =>\n          ![\n            PROJECT_MANIFEST_FILE,\n            PROJECT_FILE,\n            PROJECT_DEPENDENCY_INDEX_FILE,\n            PROJECT_DOCS_DIRECTORY,\n          ].includes(entry)\n      )\n    ) {\n      throw new HTTPError(\"Project package contains unsupported files.\", 400)\n    }\n","sourceCodeStart":926,"sourceCodeEnd":962,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/sdk/workspace/projects/backups/imports.ts#L926-L962","documentation":"Workspace (app) exports contain a db.txt dump rather than the manifest.json/project.json layout of a project package. If the extracted archive root contains db.txt, extractProjectPackage() throws this HTTP 400 at imports.ts:944 to prevent importing the wrong artifact type via the project package import path.","triggerScenarios":"Uploading a workspace/app export archive (containing db.txt) to the project-package import endpoint, triggering the check at imports.ts:943-946.","commonSituations":"Grabbing the wrong file from an export job (workspace export instead of project package); older automation scripts that used the app-export format; confusing the two download buttons/endpoints in the UI or API.","solutions":["Export a proper project package (with manifest.json/project.json) from the source workspace and import that instead","Use the workspace/app import endpoint for workspace exports rather than the project package import","Check the archive contents before importing: db.txt means it's a workspace export"],"exampleFix":"null","handlingStrategy":"validation","validationCode":"import { createReadStream } from 'fs'\nimport { parse } from 'tar'\nconst isWorkspaceExport = await new Promise<boolean>((resolve, reject) => {\n  const ws = parse({ onReadEntry: (e: any) => { if (e.path === 'db.txt' || e.path.endsWith('/db.txt')) { resolve(true); ws.abort?.() } }, onEnd: () => resolve(false) })\n  createReadStream(packagePath).pipe(ws as any)\n  ws.on('error', reject)\n})\nif (isWorkspaceExport) throw new Error('use the workspace export import endpoint, not project package import')","typeGuard":"function isProjectPackageRootEntries(entries: readonly string[]): entries is readonly string[] {\n  return !entries.includes('db.txt')\n}","tryCatchPattern":"try {\n  await importProjectPackage(file)\n} catch (err) {\n  if (err instanceof HTTPError && err.status === 400 && err.message.includes('cannot be imported as Project packages')) {\n    // route to the workspace/app import flow or obtain a project package export\n  } else {\n    throw err\n  }\n}","preventionTips":["Label exported artifacts clearly (workspace export vs project package)","Check for db.txt in the archive before calling the project import endpoint","Use the correct download action in the UI/API for the import you intend","Pin automation scripts to the endpoint matching the artifact type"],"tags":["import","wrong-artifact","http-400","validation"],"backgroundTag":"unsupported-archive-format","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}