{"record":{"id":"c3593fe001c86dcf","repo":"Budibase/budibase","slug":"project-package-dependency-index-is-invalid","errorCode":null,"errorMessage":"Project package dependency index is invalid.","messagePattern":"Project package dependency index is invalid\\.","errorType":"validation","errorClass":"HTTPError","httpStatus":400,"severity":"error","filePath":"packages/server/src/sdk/workspace/projects/backups/imports.ts","lineNumber":714,"sourceCode":"    isRecord(value) &&\n    typeof value.id === \"string\" &&\n    typeof value.name === \"string\" &&\n    isAllowedImportType(value.type) &&\n    ALLOWED_IMPORT_TYPES.has(value.type)\n  )\n}\n\nconst validateDependencyIndexShape = (\n  dependencyIndex: ProjectPackageDependencyIndex\n) => {\n  if (\n    !isRecord(dependencyIndex) ||\n    typeof dependencyIndex.rootProjectId !== \"string\" ||\n    !Array.isArray(dependencyIndex.directMembers) ||\n    !dependencyIndex.directMembers.every(validateUsedResource) ||\n    !isRecord(dependencyIndex.resources)\n  ) {\n    throw new HTTPError(\"Project package dependency index is invalid.\", 400)\n  }\n\n  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","sourceCodeStart":696,"sourceCodeEnd":732,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/sdk/workspace/projects/backups/imports.ts#L696-L732","documentation":"During project package import, Budibase validates dependency-index.json before ingesting any documents. This error means the top-level shape of dependency-index.json failed structural validation: it is not an object, or rootProjectId is not a string, or directMembers is not an array of valid used-resource entries ({id, name, type} with an allowed type), or resources is not an object. It is thrown in validateDependencyIndexShape (imports.ts:704-715) with HTTP 400 to reject malformed packages early.","triggerScenarios":"Importing a project package whose dependency-index.json is missing rootProjectId, has a non-string rootProjectId, has a directMembers array containing entries lacking id/name or with a disallowed type, or whose resources field is missing or not an object. Also triggered by hand-crafted or truncated packages.","commonSituations":"Manually edited or generated dependency-index.json (e.g. scripts that build export archives), older-format packages renamed from workspace/app exports without regenerating the index, archives corrupted or partially extracted, or JSON where resources was replaced with an array instead of a keyed object.","solutions":["Regenerate the project package using the official export flow so dependency-index.json is written with correct rootProjectId, directMembers and resources fields.","Open dependency-index.json from the package and confirm it has string rootProjectId, an object resources keyed by doc id, and directMembers entries shaped {id: string, name: string, type: <allowed type>}.","Re-export from the source environment rather than editing an old package in place; check the package formatVersion in project.json matches the target Budibase version.","Verify the archive is complete and not truncated (compare file counts against the manifest)."],"exampleFix":"// before (invalid index)\n{ \"directMembers\": [{ \"id\": \"ds_1\" }], \"resources\": [] }\n// after (valid index)\n{ \"rootProjectId\": \"app_abc\", \"directMembers\": [{ \"id\": \"ds_1\", \"name\": \"My DB\", \"type\": \"datasource\" }], \"resources\": { \"app_abc\": { \"dependencies\": [] } } }","handlingStrategy":"validation","validationCode":"const isValidIndex = (idx) =>\n  !!idx && typeof idx === \"object\" &&\n  typeof idx.rootProjectId === \"string\" &&\n  Array.isArray(idx.directMembers) &&\n  idx.directMembers.every(m => m && typeof m.id === \"string\" && typeof m.name === \"string\" && typeof m.type === \"string\") &&\n  !!idx.resources && typeof idx.resources === \"object\" && !Array.isArray(idx.resources)","typeGuard":"const isDependencyIndex = (v) =>\n  typeof v === \"object\" && v !== null &&\n  \"rootProjectId\" in v && typeof v.rootProjectId === \"string\" &&\n  Array.isArray(v.directMembers) && typeof v.resources === \"object\" && v.resources !== null","tryCatchPattern":"try {\n  await importProjectPackage(file)\n} catch (e) {\n  if (e.status === 400 && e.message.includes(\"dependency index is invalid\")) {\n    // surface 'malformed dependency-index.json' to the user, prompt re-export\n  } else throw e\n}","preventionTips":["Always produce packages with the official export endpoint, never hand-write dependency-index.json","Validate the index against the shape {rootProjectId, directMembers[{id,name,type}], resources{}} before uploading","Check the package formatVersion matches your server version","Test archives extract fully and pass a JSON parse on every file"],"tags":["validation","project-import","schema"],"backgroundTag":"dependency-index-invalid","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}