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

  1. Read the 'cleanup.merge_check_failed' warn log for the underlying err — the skipped reason string only carries the message.
  2. Fix the git/remote issue (git fetch, restore remote, verify mainRepoPath) and re-run cleanup.
  3. If offline, re-run cleanup when connectivity is restored; skipped environments are intentionally preserved.
  4. 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

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


AI-assisted analysis of coleam00/Archon@0773b97458 (2026-09-01). Data as JSON: /api/errors/6a94a41e3457d983. Report an issue: GitHub.