{"record":{"id":"4d0afc8c26c863e2","repo":"Budibase/budibase","slug":"project-package-dependency-index-does-not-match-pr","errorCode":null,"errorMessage":"Project package dependency index does not match project.json.","messagePattern":"Project package dependency index does not match project\\.json\\.","errorType":"validation","errorClass":"HTTPError","httpStatus":400,"severity":"error","filePath":"packages/server/src/sdk/workspace/projects/backups/imports.ts","lineNumber":735,"sourceCode":"  for (const resource of Object.values(dependencyIndex.resources)) {\n    if (\n      !isRecord(resource) ||\n      !Array.isArray(resource.dependencies) ||\n      !resource.dependencies.every(validateUsedResource)\n    ) {\n      throw new HTTPError(\"Project package dependency index is invalid.\", 400)\n    }\n  }\n}\n\nconst validateDependencyIndex = (\n  project: Project,\n  dependencyIndex: ProjectPackageDependencyIndex,\n  docs: ImportedDoc[],\n  manifest: ProjectPackageManifest\n) => {\n  if (dependencyIndex.rootProjectId !== project._id) {\n    throw new HTTPError(\n      \"Project package dependency index does not match project.json.\",\n      400\n    )\n  }\n\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  }","sourceCodeStart":717,"sourceCodeEnd":753,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/sdk/workspace/projects/backups/imports.ts#L717-L753","documentation":"validateDependencyIndex (imports.ts:734-739) requires the package to be internally consistent: dependency-index.json's rootProjectId must equal the _id of the project in project.json. If they differ, the index describes a different project than the package manifest claims, so import is rejected with 400.","triggerScenarios":"Importing a package where project.json's _id does not match dependencyIndex.rootProjectId — e.g. project.json was edited/regenerated (new id assigned) while the old dependency-index.json was kept, or files from two different exports were mixed into one archive.","commonSituations":"Repackaging a project under a new id by editing project.json only; merging exports; copying a dependency-index.json between packages; partial re-exports where project.json was rewritten but the index was not.","solutions":["Re-export the project so project.json and dependency-index.json are generated together and share the same rootProjectId/_id.","If editing manually, update dependencyIndex.rootProjectId to match project.json's _id (and the resources key for the root project).","Ensure the archive does not mix files from different exports; rebuild the package from the source environment.","Compare both files' ids: `jq .\"_id\" project.json` and `jq .rootProjectId dependency-index.json` must be equal."],"exampleFix":"// dependency-index.json before\n{ \"rootProjectId\": \"app_old\", ... }\n// after (match project.json _id)\n{ \"rootProjectId\": \"app_new\", ... }","handlingStrategy":"validation","validationCode":"const pkg = await readPackage(files)\nif (pkg.project._id !== pkg.dependencyIndex.rootProjectId) {\n  throw new Error(\"dependency-index rootProjectId must equal project.json _id before import\")\n}","typeGuard":null,"tryCatchPattern":"try {\n  await importProjectPackage(file)\n} catch (e) {\n  if (e.status === 400 && e.message.includes(\"does not match project.json\")) {\n    // reject/rebuild package: files come from different exports\n  } else throw e\n}","preventionTips":["Never edit project.json's _id without regenerating dependency-index.json","Build packages in one pass so all metadata files are written together","Check equality of project.json _id and index rootProjectId as a pre-import lint","Avoid mixing files between exported archives"],"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"}