{"record":{"id":"157d6132e5ed6a6e","repo":"Budibase/budibase","slug":"project-package-dependency-index-references-missin","errorCode":null,"errorMessage":"Project package dependency index references missing docs.","messagePattern":"Project package dependency index references missing docs\\.","errorType":"validation","errorClass":"HTTPError","httpStatus":400,"severity":"error","filePath":"packages/server/src/sdk/workspace/projects/backups/imports.ts","lineNumber":767,"sourceCode":"    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)) {\n      return\n    }\n    reachable.add(id)\n    for (const dependency of dependencyIndex.resources[id]?.dependencies ||\n      []) {\n      if (dependencyIndex.resources[dependency.id]) {\n        visit(dependency.id)\n      }\n    }","sourceCodeStart":749,"sourceCodeEnd":785,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/sdk/workspace/projects/backups/imports.ts#L749-L785","documentation":"The inverse check of error 644: every id listed in dependencyIndex.resources (except the root project id) must have a corresponding doc in the package (imports.ts:765-772). If the index references a resource id for which no doc file exists, import is rejected with 400 because the package is incomplete relative to its own index.","triggerScenarios":"Importing a package where dependency-index.json lists resource ids that have no matching doc files — docs were deleted from the archive, files were lost during re-zipping, or the index was generated from a fuller export than the docs shipped.","commonSituations":"Manually pruning docs (e.g. removing a screen) without updating dependency-index.json; partial/corrupted archives; extracting or copying the package and losing some JSON files; git-ignored or size-limited uploads dropping files.","solutions":["Re-export the full project package so all indexed docs are present.","Delete the corresponding entries from dependencyIndex.resources for resources you intentionally removed.","Restore the missing doc files into the package, with filenames matching the expected doc path convention.","Compare `jq '.resources | keys' dependency-index.json` against the doc ids present in the archive and reconcile both directions."],"exampleFix":"// before: index lists ta_2 but ta_2.json missing\n// after: remove from index (or restore ta_2.json)\n\"resources\": { \"ta_1\": { \"dependencies\": [] } } // ta_2 entry deleted","handlingStrategy":"validation","validationCode":"const docIds = new Set(pkg.docs.map(d => d._id))\nconst missing = Object.keys(pkg.dependencyIndex.resources)\n  .filter(id => id !== pkg.dependencyIndex.rootProjectId && !docIds.has(id))\nif (missing.length) throw new Error(`Index references missing docs: ${missing.join(\", \")}`)","typeGuard":null,"tryCatchPattern":"try {\n  await importProjectPackage(file)\n} catch (e) {\n  if (e.status === 400 && e.message.includes(\"references missing docs\")) {\n    // restore missing doc files or prune index entries, then retry\n  } else throw e\n}","preventionTips":["When deleting resources from a package, remove their index entries too","Verify archive completeness (file counts) before upload","Avoid manually pruning doc files; re-export with the resources excluded instead","Run a two-way diff of doc ids vs index keys as a pre-upload check"],"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"}