{"record":{"id":"5361398c07162748","repo":"abhigyanpatwari/GitNexus","slug":"refusing-to-delete-storage-error-message-the-registry","errorCode":null,"errorMessage":"Refusing to delete storage: ${error?.message ?? 'the registry storage path is invalid'}","messagePattern":"Refusing to delete storage: (.+?)","errorType":"exception","errorClass":"StorageDeletionError","httpStatus":null,"severity":"error","filePath":"gitnexus/src/storage/storage-resolver.ts","lineNumber":683,"sourceCode":"export const requireDeletableStoragePath = async (entry: {\n  path: string;\n  storagePath: string;\n}): Promise<string> => {\n  let repoPath: string;\n  let actualStoragePath: string;\n  try {\n    repoPath = resolveRepoPath(entry.path);\n    actualStoragePath = validateConfiguredStoragePath(entry.storagePath);\n  } catch (error) {\n    const rawStoragePath =\n      typeof entry.storagePath === 'string'\n        ? path.resolve(entry.storagePath)\n        : String(entry.storagePath);\n    const fallbackRepoPath =\n      typeof entry.path === 'string' && entry.path.length > 0 && !entry.path.includes('\\0')\n        ? entry.path\n        : process.cwd();\n    throw new StorageDeletionError(\n      defaultStoragePath(fallbackRepoPath),\n      rawStoragePath,\n      undefined,\n      error instanceof Error ? error.message : 'the registry storage path is invalid',\n    );\n  }\n\n  const expectedStoragePath = defaultStoragePath(repoPath);\n  const storageIsLocal = isRepositoryLocalStoragePath(repoPath, actualStoragePath);\n  const comparableStorage = comparablePath(actualStoragePath);\n  const comparableRepo = comparablePath(repoPath);\n  const comparableRoot = comparablePath(path.parse(actualStoragePath).root);\n  if (\n    samePath(comparableStorage, comparableRoot) ||\n    samePath(comparableStorage, comparableRepo) ||\n    isPathAncestor(comparableStorage, comparableRepo)\n  ) {\n    throw new StorageDeletionError(","sourceCodeStart":665,"sourceCodeEnd":701,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/ac9a4e9abd8fd3058c070b72c23402a4f887929a/gitnexus/src/storage/storage-resolver.ts#L665-L701","documentation":"A StorageDeletionError raised by the storage deletion path when it cannot resolve a safe, valid storage path from the registry entry — the underlying error message is embedded ('the registry storage path is invalid' when no error object is present). GitNexus refuses to delete anything rather than guess which directory rm should target.","triggerScenarios":"Requesting deletion of a repo (CLI clean/remove or HTTP DELETE /api/repo) where the registry entry's storagePath is missing, malformed (e.g. contains a NUL byte), or fails validation, so no trustworthy deletion target can be computed.","commonSituations":"A hand-edited or corrupted registry file; a registry entry written by an older GitNexus version with a different storagePath shape; a moved repository whose registry entry no longer resolves.","solutions":["Inspect the registry entry and correct or remove the malformed storagePath value, then retry the deletion.","Re-register the repository (re-run analyze) so a fresh, valid registry entry replaces the broken one.","Manually remove the storage directory only after verifying the path yourself, then clean up the registry entry.","Use the detailed embedded error message to identify exactly why validation failed (e.g. invalid characters, empty string)."],"exampleFix":"// before (corrupt entry)\n{ \"name\": \"myrepo\", \"storagePath\": \"\" }\n// after\n{ \"name\": \"myrepo\", \"storagePath\": \"/work/myrepo/.gitnexus\" }","handlingStrategy":"try-catch","validationCode":"const entry = await getRegistryEntry(repoName);\nconst sp = entry?.storagePath;\nif (typeof sp !== 'string' || sp.length === 0 || sp.includes('\\0')) {\n  console.error('Registry storagePath is malformed; fix or re-register the repo');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await deleteRepoStorage(repoName);\n} catch (err) {\n  if (err instanceof StorageDeletionError) {\n    console.error(`Refusing delete: ${err.reason}. Inspect the registry entry for ${repoName}.`);\n  } else throw err;\n}","preventionTips":["Don't hand-edit the registry file; use CLI commands to register/remove repos.","Validate registry JSON after migrating between GitNexus versions.","Back up the registry before manual cleanup operations.","Re-run analyze to regenerate a valid registry entry if one is corrupt."],"tags":["storage","deletion","registry"],"backgroundTag":"invalid-argument-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"}