eyaltoledano/claude-task-master · error
Repository validation failed: ${errorMessage}
Error message
Repository validation failed: ${errorMessage} What it means
validateRepository() in GitAdapter wraps any failure from simple-git's status() call into `Repository validation failed: <message>`. It is thrown only after confirming the path IS a git repo, so this means the repo exists but its metadata is unreadable or corrupted (or the git binary failed). The library throws it so callers get a consistent, prefixed error during pre-flight integrity checks.
Source
Thrown at packages/tm-core/src/modules/git/adapters/git-adapter.ts:173
*
* @example
* await git.validateRepository();
* console.log('Repository is valid');
*/
async validateRepository(): Promise<void> {
// Check if it's a git repository
const isRepo = await this.isGitRepository();
if (!isRepo) {
throw new Error(`not a git repository: ${this.projectPath}`);
}
// Try to get repository status to verify it's not corrupted
try {
await this.git.status();
} catch (error) {
const errorMessage =
error instanceof Error ? error.message : String(error);
throw new Error(`Repository validation failed: ${errorMessage}`);
}
}
/**
* Ensures we're in a valid git repository before performing operations.
* Convenience method that throws descriptive errors.
*
* @returns {Promise<void>}
* @throws {Error} If not in a valid git repository
*
* @example
* await git.ensureGitRepository();
* // Safe to perform git operations after this
*/
async ensureGitRepository(): Promise<void> {
const isRepo = await this.isGitRepository();
if (!isRepo) {
throw new Error(View on GitHub (pinned to c0c98d367c)
Solutions
- Read the wrapped inner message after 'Repository validation failed: ' — it names the actual git failure.
- Remove a stale lock file if present: rm .git/index.lock (only when no git process is running).
- Run `git status` manually in the directory to reproduce and confirm it's a repo-level problem, not your code.
- Fix permissions on .git (chown/chmod) if the error is EACCES/permission denied.
- If the repo is corrupted, re-clone or run `git fsck` / restore .git from backup.
Example fix
// before
await git.validateRepository(); // throws opaque wrapper
// after
try {
await git.validateRepository();
} catch (e) {
console.error('repo invalid:', (e as Error).message.replace('Repository validation failed: ', ''));
} Defensive patterns
Strategy: try-catch
Validate before calling
import { execFile } from 'child_process';
execFile('git', ['-C', projectPath, 'status', '--porcelain'], (err) => {
if (err) console.warn('repo status failed:', err.message);
}); Type guard
function isRepoValidationError(e: unknown): e is Error & { message: string } {
return e instanceof Error && e.message.startsWith('Repository validation failed: ');
} Try / catch
try {
await git.validateRepository();
} catch (e) {
if (isRepoValidationError(e)) {
const gitReason = e.message.replace('Repository validation failed: ', '');
// surface gitReason; check for index.lock / permission issues
}
throw e;
} Prevention
- Run validateRepository() once at startup and fail fast with the unwrapped inner message.
- Monitor for leftover .git/index.lock after crashed runs.
- Keep the git binary installed and on PATH in CI images.
- Avoid sharing .git across users/containers with mismatched file permissions.
When it happens
Trigger: Calling gitAdapter.validateRepository() when simple-git's this.git.status() throws — e.g. corrupted .git directory, missing HEAD or objects, permission denied on .git, broken index.lock, or git binary errors despite a repo being detected by isGitRepository().
Common situations: Interrupted git operations leaving a stale .git/index.lock; disk corruption or partially cloned repos; .git owned by another user (WSL/Windows permission issues); a bare or invalid checkout where status fails; git version incompatibilities.
Related errors
- Failed to fetch tasks from any tag. First error: ${failedTag
- ${authCheck.error}
- Project path is required
- Project path must be an absolute path
- not a git repository: ${this.projectPath}
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/f146d065e8af2bb1.
Report an issue: GitHub.