abhigyanpatwari/GitNexus · error · StorageDeletionError

Refusing to delete storage

Error message

Refusing to delete storage: ${error?.message ?? 'the registry storage path is invalid'}

What it means

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.

Solutions

  1. Inspect the registry entry and correct or remove the malformed storagePath value, then retry the deletion.
  2. Re-register the repository (re-run analyze) so a fresh, valid registry entry replaces the broken one.
  3. Manually remove the storage directory only after verifying the path yourself, then clean up the registry entry.
  4. Use the detailed embedded error message to identify exactly why validation failed (e.g. invalid characters, empty string).

Example fix

// before (corrupt entry)
{ "name": "myrepo", "storagePath": "" }
// after
{ "name": "myrepo", "storagePath": "/work/myrepo/.gitnexus" }
Defensive patterns

Strategy: try-catch

Validate before calling

const entry = await getRegistryEntry(repoName);
const sp = entry?.storagePath;
if (typeof sp !== 'string' || sp.length === 0 || sp.includes('\0')) {
  console.error('Registry storagePath is malformed; fix or re-register the repo');
}

Try / catch

try {
  await deleteRepoStorage(repoName);
} catch (err) {
  if (err instanceof StorageDeletionError) {
    console.error(`Refusing delete: ${err.reason}. Inspect the registry entry for ${repoName}.`);
  } else throw err;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of abhigyanpatwari/GitNexus@ac9a4e9abd (2026-09-15). Data as JSON: /api/errors/5361398c07162748. Report an issue: GitHub.

Appendix: source

Thrown at gitnexus/src/storage/storage-resolver.ts:683

export const requireDeletableStoragePath = async (entry: {
  path: string;
  storagePath: string;
}): Promise<string> => {
  let repoPath: string;
  let actualStoragePath: string;
  try {
    repoPath = resolveRepoPath(entry.path);
    actualStoragePath = validateConfiguredStoragePath(entry.storagePath);
  } catch (error) {
    const rawStoragePath =
      typeof entry.storagePath === 'string'
        ? path.resolve(entry.storagePath)
        : String(entry.storagePath);
    const fallbackRepoPath =
      typeof entry.path === 'string' && entry.path.length > 0 && !entry.path.includes('\0')
        ? entry.path
        : process.cwd();
    throw new StorageDeletionError(
      defaultStoragePath(fallbackRepoPath),
      rawStoragePath,
      undefined,
      error instanceof Error ? error.message : 'the registry storage path is invalid',
    );
  }

  const expectedStoragePath = defaultStoragePath(repoPath);
  const storageIsLocal = isRepositoryLocalStoragePath(repoPath, actualStoragePath);
  const comparableStorage = comparablePath(actualStoragePath);
  const comparableRepo = comparablePath(repoPath);
  const comparableRoot = comparablePath(path.parse(actualStoragePath).root);
  if (
    samePath(comparableStorage, comparableRoot) ||
    samePath(comparableStorage, comparableRepo) ||
    isPathAncestor(comparableStorage, comparableRepo)
  ) {
    throw new StorageDeletionError(

View on GitHub (pinned to ac9a4e9abd)