{"record":{"id":"71ab93f4b71f71df","repo":"Budibase/budibase","slug":"project-package-contains-docs-not-listed-in-depend","errorCode":null,"errorMessage":"Project package contains docs not listed in dependency-index.json.","messagePattern":"Project package contains docs not listed in dependency-index\\.json\\.","errorType":"validation","errorClass":"HTTPError","httpStatus":400,"severity":"error","filePath":"packages/server/src/sdk/workspace/projects/backups/imports.ts","lineNumber":758,"sourceCode":"\n  const actualDocIds = new Set(docs.map(doc => doc.doc._id!))\n  const expectedDocIds = new Set(\n    Object.keys(dependencyIndex.resources).filter(\n      id => id !== dependencyIndex.rootProjectId\n    )\n  )\n\n  if (!dependencyIndex.resources[dependencyIndex.rootProjectId]) {\n    throw new HTTPError(\n      \"Project package docs do not match dependency-index.json.\",\n      400\n    )\n  }\n\n  for (const doc of docs) {\n    validateDocMatchesPath(doc)\n    if (!expectedDocIds.has(doc.doc._id!)) {\n      throw new HTTPError(\n        \"Project package contains docs not listed in dependency-index.json.\",\n        400\n      )\n    }\n  }\n\n  for (const expectedDocId of expectedDocIds) {\n    if (!actualDocIds.has(expectedDocId)) {\n      throw new HTTPError(\n        \"Project package dependency index references missing docs.\",\n        400\n      )\n    }\n  }\n\n  const reachable = new Set<string>()\n  const visit = (id: string) => {\n    if (reachable.has(id)) {","sourceCodeStart":740,"sourceCodeEnd":776,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/sdk/workspace/projects/backups/imports.ts#L740-L776","documentation":"Every document in the package must be declared in dependency-index.json (imports.ts:755-763). After checking each doc's stored path matches its id (validateDocMatchesPath), any doc whose _id is not among the index's resources keys (excluding the root) triggers this 400 error. It guards against orphan or smuggled docs in the archive.","triggerScenarios":"Importing a package that contains extra JSON docs (in the docs directory) with ids absent from dependencyIndex.resources — e.g. files added to the archive after export, stale docs left over from a previous export, or a dependency-index.json that wasn't regenerated when docs changed.","commonSituations":"Manually adding screens/tables/rows JSON files to an extracted package; re-zipping an older package with extra files; export tooling that appends docs but never updates the index.","solutions":["Regenerate the package via the export flow so dependency-index.json lists every doc actually shipped.","Remove the undeclared doc files from the package, or add corresponding resources entries with their id and dependencies.","Diff the archive's doc file ids against `jq '.resources | keys' dependency-index.json` and reconcile.","Rebuild the archive from the original export rather than patching an extracted copy."],"exampleFix":"// before: package contains doc ta_99 not in index\n// after: either delete ta_99.json or add to dependency-index.json\n\"resources\": { \"ta_99\": { \"dependencies\": [] }, ... }","handlingStrategy":"validation","validationCode":"const indexIds = new Set(Object.keys(pkg.dependencyIndex.resources))\nconst extra = pkg.docs.filter(d => !indexIds.has(d._id))\nif (extra.length) throw new Error(`Undeclared docs in package: ${extra.map(d => d._id).join(\", \")}`)","typeGuard":null,"tryCatchPattern":"try {\n  await importProjectPackage(file)\n} catch (e) {\n  if (e.status === 400 && e.message.includes(\"not listed in dependency-index.json\")) {\n    // strip the undeclared docs or regenerate the index, then retry once\n  } else throw e\n}","preventionTips":["Never add doc files to an extracted package without updating dependency-index.json","Re-zip packages from a clean export, not from modified extractions","Diff doc ids against resources keys before uploading","Keep package build steps scripted so the index is always regenerated"],"tags":["validation","project-import","consistency"],"backgroundTag":"package-manifest-mismatch","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}