{"record":{"id":"140f41c391fb08db","repo":"Budibase/budibase","slug":"project-package-contains-too-many-docs","errorCode":null,"errorMessage":"Project package contains too many docs.","messagePattern":"Project package contains too many docs\\.","errorType":"validation","errorClass":"HTTPError","httpStatus":400,"severity":"error","filePath":"packages/server/src/sdk/workspace/projects/backups/imports.ts","lineNumber":1001,"sourceCode":"    const [manifest, project, dependencyIndex] = await Promise.all([\n      readJsonFile<ProjectPackageManifest>(manifestPath),\n      readJsonFile<Project>(projectPath),\n      readJsonFile<ProjectPackageDependencyIndex>(dependencyIndexPath),\n    ])\n\n    validateManifest(manifest)\n    validateProject(project)\n    validateDependencyIndexShape(dependencyIndex)\n\n    const docFiles = await fsp\n      .access(docsPath)\n      .then(() =>\n        packageFiles.filter(filePath => filePath.startsWith(docsPath))\n      )\n      .catch(() => [])\n\n    if (docFiles.length > MAX_PACKAGE_DOCS) {\n      throw new HTTPError(\"Project package contains too many docs.\", 400)\n    }\n    if (docFiles.some(filePath => !filePath.endsWith(\".json\"))) {\n      throw new HTTPError(\n        \"Project package contains unsupported doc files.\",\n        400\n      )\n    }\n\n    const docs = await Promise.all(\n      docFiles\n        .filter(filePath => filePath.endsWith(\".json\"))\n        .map(async filePath => {\n          const doc = await readJsonFile<AnyDocument>(filePath)\n          if (!isRecord(doc) || typeof doc._id !== \"string\") {\n            throw new HTTPError(\n              `Project package contains an invalid doc in '${basename(filePath)}'.`,\n              400\n            )","sourceCodeStart":983,"sourceCodeEnd":1019,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/sdk/workspace/projects/backups/imports.ts#L983-L1019","documentation":"This error is thrown by extractProjectPackage when validating a Project import package's docs directory. The number of JSON doc files found under the package docs path exceeds MAX_PACKAGE_DOCS, so the server refuses the import to bound resource usage. It is a hard 400 validation limit, not a transient failure.","triggerScenarios":"Calling importProject with a package whose extracted docs directory contains more files than MAX_PACKAGE_DOCS. Typically produced by hand-crafting or tooling-generating a package rather than using the official exporter.","commonSituations":"Importing a Project package built by scripts that dump an entire workspace DB export into the docs folder; concatenating multiple exports; an old or third-party export tool with different doc limits.","solutions":["Trim the docs directory in the package so it contains at most MAX_PACKAGE_DOCS files","Split the content into multiple Project packages and import them separately","Regenerate the package with the official Budibase export, which enforces the doc limit","Increase MAX_PACKAGE_DOCS only if you control the deployment and truly need larger packages"],"exampleFix":"// before (package with hundreds of dumped docs)\n// docs/row-001.json ... docs/row-900.json\n// after: keep only docs the exporter produces, remove bulk row dumps\n$ zip -d project.tar.gz 'docs/row-*.json'","handlingStrategy":"validation","validationCode":"import { readdir } from \"fs/promises\"\nconst docFiles = (await readdir(\"docs\")).filter(f => f.endsWith(\".json\"))\nif (docFiles.length > MAX_PACKAGE_DOCS) throw new Error(\"Too many docs in package\")","typeGuard":"null","tryCatchPattern":"try {\n  await sdk.projects.importProject(file)\n} catch (e) {\n  if (String(e.message).includes(\"too many docs\")) {\n    // split the package and retry\n  }\n}","preventionTips":["Always build packages with the official exporter, which respects the doc limit","Count docs/*.json before importing: readdir + filter endsWith('.json')","Split large workspaces into multiple Project packages"],"tags":["validation","import","project-package","http-400"],"backgroundTag":"project-package-validation-failed","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}