coleam00/Archon · warning
merge check failed: ${err.message}
Error message
merge check failed: ${err.message} What it means
cleanupMergedWorktrees evaluates each isolation environment with isSafeToRemove (merge state, PR state, remote refs). If that safety check itself throws — an unexpected error rather than a 'not safe' verdict — the environment is skipped, never removed, and the branch is recorded in result.skipped with this reason, plus a 'cleanup.merge_check_failed' warn log so the skip is debuggable from the cleanup report.
Source
Thrown at packages/core/src/services/cleanup-service.ts:864
remoteMainRef,
prStateCache,
includeClosed,
remote
);
safe = decision.safe;
openPr = decision.openPr;
} catch (error) {
const err = error as Error;
// Log before skipping — silent skips make transient git/network failures
// impossible to debug from the cleanup report alone.
getLog().warn(
{ err, branchName: env.branch_name, repoPath: mainRepoPath },
'cleanup.merge_check_failed'
);
result.skipped.push({
branchName: env.branch_name,
reason: `merge check failed: ${err.message}`,
});
continue;
}
if (!safe) {
if (openPr) {
result.skipped.push({
branchName: env.branch_name,
reason: 'PR is open (active review)',
});
}
continue;
}
// Check for uncommitted changes or a live owning run
const blocker = await getRemovalBlocker(env);
if (blocker) {
result.skipped.push({ branchName: env.branch_name, reason: blocker.display });
continue;
}View on GitHub (pinned to 0773b97458)
Solutions
- Read the 'cleanup.merge_check_failed' warn log for the underlying err — the skipped reason string only carries the message.
- Fix the git/remote issue (git fetch, restore remote, verify mainRepoPath) and re-run cleanup.
- If offline, re-run cleanup when connectivity is restored; skipped environments are intentionally preserved.
- Confirm the codebase's git remote and remoteMainRef configuration match the actual repository setup.
Defensive patterns
Strategy: try-catch
Validate before calling
// per environment, before relying on cleanup results
const report = await cleanupMergedWorktrees(codebaseId, mainRepoPath);
const blocked = report.skipped.filter(s => s.reason.startsWith('merge check failed:'));
if (blocked.length > 0) {
console.warn('git/network issues during cleanup; rerun after fixing:', blocked.map(b => b.branchName));
} Type guard
function isMergeCheckSkip(s: { reason: string }): boolean {
return s.reason.startsWith('merge check failed: ');
} Try / catch
try {
const decision = await isSafeToRemove(repoPath, branchName, remoteMainRef, prStateCache, includeClosed, remote);
safe = decision.safe;
} catch (error) {
const err = error as Error;
getLog().warn({ err, branchName, repoPath }, 'cleanup.merge_check_failed');
result.skipped.push({ branchName, reason: `merge check failed: ${err.message}` });
continue; // never remove when safety cannot be proven
} Prevention
- Ensure the main repo has a valid remote and run `git fetch` periodically.
- Verify mainRepoPath exists and is the correct checkout before cleanup runs.
- Monitor cleanup.merge_check_failed warnings for recurring git/API issues.
- Re-run cleanup after transient network failures instead of assuming environments were removed.
When it happens
Trigger: isSafeToRemove throwing while running git commands (merge-base / rev-parse against remoteMainRef) or querying PR state for env.branch_name: missing repo at mainRepoPath, missing/misconfigured remote, network failure fetching remote refs, corrupt git state, or a PR-API failure not absorbed by the prStateCache.
Common situations: No network so remote refs cannot be resolved; remote renamed or deleted; repo moved so mainRepoPath is invalid; GitHub API rate limit or auth failure while checking PR state; unexpected branch_name patterns in the environments table.
Related errors
- Failed to create worktree for PR #${prNumber}: ${err.message
- Failed to clone ${owner}/${repo}: ${'message' in cloneResult
- Failed to clone repository: ${safeErr.message}
- Cannot verify worktree ownership at ${worktreePath}: ${(erro
- Cannot adopt ${worktreePath}: .git pointer is not a git-work
AI-assisted analysis of coleam00/Archon@0773b97458 (2026-09-01).
Data as JSON: /api/errors/6a94a41e3457d983.
Report an issue: GitHub.