{"record":{"id":"6c996cb625b524e1","repo":"abhigyanpatwari/GitNexus","slug":"label-must-be-an-absolute-non-empty-path","errorCode":null,"errorMessage":"${label} must be an absolute, non-empty path.","messagePattern":"(.+?) must be an absolute, non-empty path\\.","errorType":"validation","errorClass":"InvalidStoragePathError","httpStatus":null,"severity":"error","filePath":"gitnexus/src/storage/storage-resolver.ts","lineNumber":185,"sourceCode":"\nconst filesystemErrorDetail = (error: unknown): string => {\n  const code = (error as NodeJS.ErrnoException)?.code;\n  return code ? `${code}: ${(error as Error)?.message ?? String(error)}` : String(error);\n};\n\nconst resolveRepoPath = (value: string): string => {\n  if (typeof value !== 'string' || value.length === 0) {\n    throw new InvalidStoragePathError('Repository path must be non-empty.');\n  }\n  if (value.includes('\\0')) {\n    throw new InvalidStoragePathError('Repository path must not contain a NUL character.');\n  }\n  return path.resolve(value);\n};\n\nconst validateAbsolutePath = (value: string, label: string): string => {\n  if (typeof value !== 'string' || value.length === 0) {\n    throw new InvalidStoragePathError(`${label} must be an absolute, non-empty path.`);\n  }\n  if (value.includes('\\0')) {\n    throw new InvalidStoragePathError(`${label} must not contain a NUL character.`);\n  }\n  if (!path.isAbsolute(value)) {\n    throw new InvalidStoragePathError(`${label} must be an absolute path.`);\n  }\n  return path.resolve(value);\n};\n\n// Mirror registry lookup semantics without importing repo-manager and creating a cycle.\nconst canonicalRegistryPath = (value: string): string => {\n  const resolved = path.resolve(value);\n  try {\n    return stripWindowsLongPathPrefix(fs.realpathSync.native(resolved));\n  } catch {\n    return stripWindowsLongPathPrefix(resolved);\n  }","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/ac9a4e9abd8fd3058c070b72c23402a4f887929a/gitnexus/src/storage/storage-resolver.ts#L167-L203","documentation":"validateAbsolutePath is the strict validator for absolute storage configuration paths. It throws when the labeled value is empty or not a string, producing a message like '<label> must be an absolute, non-empty path.' It is used for resolved storage roots, ownership metadata, and root configuration, where a relative path is never acceptable.","triggerScenarios":"Calling resolved(), root(), or readOwnershipMetadata() with an empty string or relative path for a value labeled 'Storage path'/'Storage root' etc., e.g. GITNEXUS_STORAGE_PATH set to 'repos' instead of '/data/repos'.","commonSituations":"Env var GITNEXUS_STORAGE_PATH / GITNEXUS_STORAGE_ROOT set to a relative path; config file with missing/blank absolute path field; programmatic use passing cwd-relative paths assuming they'd be resolved.","solutions":["Convert to an absolute path before the call: path.resolve(value) (relative paths resolve against cwd, which may not be what you want — prefer path.isAbsolute check).","Fix the env/config value to a full absolute path (e.g. export GITNEXUS_STORAGE_PATH=/var/lib/gitnexus).","Ensure the value is actually a string; JSON configs sometimes carry null/numbers where a path is expected."],"exampleFix":"// before\nconfiguredStoragePath(process.env.GITNEXUS_STORAGE_PATH ?? 'storage');\n// after\nconst p = process.env.GITNEXUS_STORAGE_PATH ?? path.join(os.homedir(), '.gitnexus-storage');\nif (!path.isAbsolute(p)) throw new Error(`Storage path must be absolute: ${p}`);\nconfiguredStoragePath(p);","handlingStrategy":"validation","validationCode":"if (typeof value !== 'string' || value.length === 0 || !path.isAbsolute(value)) {\n  throw new Error(`${label} must be a non-empty absolute path (got: ${JSON.stringify(value)})`);\n}","typeGuard":"const isAbsoluteNonEmptyPath = (v: unknown): v is string =>\n  typeof v === 'string' && v.length > 0 && path.isAbsolute(v);","tryCatchPattern":"try {\n  const p = resolved(value);\n} catch (e) {\n  if (e instanceof InvalidStoragePathError) throw new Error(`storage config invalid: ${e.message}`);\n  throw e;\n}","preventionTips":["Store absolute paths in env/config (no './' or bare names).","Resolve config paths once at startup against an explicit base, not cwd.","Validate with path.isAbsolute before calling any resolver API."],"tags":["validation","absolute-path","config"],"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"}