{"record":{"id":"d3f3dd68d202b871","repo":"abhigyanpatwari/GitNexus","slug":"storage-requirement-not-met-foreign-external-slot-is-not","errorCode":null,"errorMessage":"Storage requirement not met: foreign external slot is not adoptable","messagePattern":"Storage requirement not met: foreign external slot is not adoptable","errorType":"exception","errorClass":"StorageRequirementError","httpStatus":null,"severity":"error","filePath":"gitnexus/src/storage/storage-resolver.ts","lineNumber":622,"sourceCode":"  path: string;\n  storagePath: string;\n}): Promise<StorageInspection> => inspectStoragePath(entry.storagePath, entry.path);\n\nconst requireInspectedStoragePath = (\n  inspection: StorageInspection,\n  requirements: StorageRequirements,\n): string => {\n  if (!requirements.allowedStates.includes(inspection.state)) {\n    throw new StorageRequirementError(inspection, requirements);\n  }\n  // `foreign` is only adoptable for this checkout's own `.gitnexus`. An\n  // external slot that names another repository stays rejected even when the\n  // caller opted into `foreign` (analyze/index --force).\n  if (\n    inspection.state === 'foreign' &&\n    !isRepositoryLocalStoragePath(inspection.repoPath, inspection.storagePath)\n  ) {\n    throw new StorageRequirementError(inspection, {\n      ...requirements,\n      allowedStates: requirements.allowedStates.filter((state) => state !== 'foreign'),\n    });\n  }\n  if (requirements.requireCodeIndexDB && !inspection.hasCodeIndexDB) {\n    throw new StorageRequirementError(inspection, requirements);\n  }\n  return inspection.storagePath;\n};\n\n/** Resolve and validate storage selected from a repository path. */\nexport const requireStoragePath = async (\n  repoPath: string,\n  requirements: StorageRequirements,\n): Promise<string> =>\n  requireInspectedStoragePath(await inspectResolvedStorage(repoPath), requirements);\n\n/** Validate the exact storage path persisted in a registry entry. */","sourceCodeStart":604,"sourceCodeEnd":640,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/ac9a4e9abd8fd3058c070b72c23402a4f887929a/gitnexus/src/storage/storage-resolver.ts#L604-L640","documentation":"A StorageRequirementError raised when the inspected storage is in state 'foreign' but the slot's path does not correspond to this checkout's own .gitnexus (isRepositoryLocalStoragePath fails). Even if the caller opted into foreign slots via analyze/index --force, GitNexus refuses to adopt an external slot that names a different repository, because adopting it would destroy or overwrite another repo's index.","triggerScenarios":"Running analyze/index --force while GITNEXUS_STORAGE_PATH (or the resolved storage path) points to an external slot whose registered repoPath is a different repository than the one being analyzed.","commonSituations":"Sharing one external index directory between multiple repos via GITNEXUS_STORAGE_PATH; copying a .gitnexus directory from another project; a moved/renamed repo reusing an old external slot.","solutions":["Stop sharing the storage path: give this repo its own storage directory (default <repo>/.gitnexus) and re-run.","If GITNEXUS_STORAGE_PATH is set, clear it or set it to a slot created for this repository.","Re-create the index fresh for this repository rather than adopting the foreign slot.","Check `gitnexus list-repos` / inspection metadata to see which repo owns the external slot before reusing it."],"exampleFix":"// before\nGITNEXUS_STORAGE_PATH=/data/indexes/other-repo npx gitnexus analyze --force\n// after\nunset GITNEXUS_STORAGE_PATH && npx gitnexus analyze","handlingStrategy":"validation","validationCode":"const inspection = await inspectStoragePath(storagePath);\nif (inspection.state === 'foreign' && inspection.repoPath !== process.cwd()) {\n  throw new Error('External storage slot belongs to another repo: ' + inspection.repoPath);\n}","typeGuard":"const isOwnStorage = (i: StorageInspection): boolean =>\n  i.state !== 'foreign' || isRepositoryLocalStoragePath(i.repoPath, i.storagePath);","tryCatchPattern":"try {\n  await requireStoragePath(repoPath, { allowedStates: [...,'foreign'] });\n} catch (err) {\n  if (err instanceof StorageRequirementError && err.inspection.state === 'foreign') {\n    // re-point storage at this repo's own .gitnexus and retry\n  } else throw err;\n}","preventionTips":["Never point GITNEXUS_STORAGE_PATH at a slot created for a different repository.","One external storage slot per repository; name directories after the repo.","Check `gitnexus list-repos` ownership metadata before adopting shared slots.","After moving/renaming a repo, re-index instead of reusing old external slots."],"tags":["storage","foreign-slot","safety-guard"],"backgroundTag":"invalid-config-value","analyzedSha":"ac9a4e9abd8fd3058c070b72c23402a4f887929a","analyzedAt":"2026-09-15T23:29:44.066Z","contentChangedAt":"2026-09-15T23:29:44.066Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}