{"record":{"id":"96ae02b4efad5f76","repo":"abhigyanpatwari/GitNexus","slug":"repository-path-must-be-non-empty","errorCode":null,"errorMessage":"Repository path must be non-empty.","messagePattern":"Repository path must be non-empty\\.","errorType":"validation","errorClass":"InvalidStoragePathError","httpStatus":null,"severity":"error","filePath":"gitnexus/src/storage/storage-resolver.ts","lineNumber":175,"sourceCode":"const samePath = (left: string, right: string): boolean =>\n  process.platform === 'win32' ? left.toLowerCase() === right.toLowerCase() : left === right;\n\nconst isRepositoryLocalStoragePath = (repoPath: string, storagePath: string): boolean =>\n  samePath(comparablePath(defaultStoragePath(repoPath)), comparablePath(storagePath));\n\nconst isMissingFilesystemError = (error: unknown): boolean => {\n  const code = (error as NodeJS.ErrnoException)?.code;\n  return code === 'ENOENT' || code === 'ENOTDIR';\n};\n\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);","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/ac9a4e9abd8fd3058c070b72c23402a4f887929a/gitnexus/src/storage/storage-resolver.ts#L157-L193","documentation":"resolveRepoPath validates the raw repository path input before path.resolve. A zero-length (or non-string) value is rejected with InvalidStoragePathError('Repository path must be non-empty.'). Every downstream resolver helper (canonicalRepoPath, defaultStoragePath, resolvedRepoPath, requireDeletableStoragePath) funnels through it, so this fires on the first storage API call with an empty repo path.","triggerScenarios":"Passing '' (or undefined coerced via String()) as the repoPath argument to canonicalRepoPath/defaultStoragePath/resolvedRepoPath, or a config/env value that resolves to an empty string.","commonSituations":"Missing or empty CLI flag / config field for the repository path; env var like GITNEXUS_... left unset and defaulted to ''; calling the storage API programmatically before the caller supplied a repo root.","solutions":["Supply a valid repository path (e.g. process.cwd() or the project root) to the storage call.","Check the config/env source that should hold the path; fix the empty value before calling.","Add an early guard in your caller to fail with a clear message when the path is empty.","If path comes from argv, validate arg count/presence before invoking storage APIs."],"exampleFix":"// before\nconst repoPath = config.repoPath ?? '';\nconst canonical = await canonicalRepoPath(repoPath);\n// after\nconst repoPath = config.repoPath ?? process.cwd();\nif (typeof repoPath !== 'string' || repoPath.length === 0) throw new Error('repoPath is required');\nconst canonical = await canonicalRepoPath(repoPath);","handlingStrategy":"validation","validationCode":"if (typeof repoPath !== 'string' || repoPath.trim().length === 0) {\n  throw new Error('repoPath is required and must be a non-empty string');\n}","typeGuard":"const isNonEmptyString = (v: unknown): v is string => typeof v === 'string' && v.length > 0;","tryCatchPattern":"try {\n  return await canonicalRepoPath(repoPath);\n} catch (e) {\n  if (e instanceof InvalidStoragePathError) throw new Error(`bad repo path input: ${e.message}`);\n  throw e;\n}","preventionTips":["Default repoPath to process.cwd() instead of an empty string.","Validate CLI/config path fields at startup before any storage call.","Never pass optional/possibly-undefined values straight into storage APIs."],"tags":["validation","empty-string","storage"],"backgroundTag":"empty-required-field","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"}