paperclipai/paperclip · error · Error
Failed to compute a merged git tree for SSH workspace restor
Error message
Failed to compute a merged git tree for SSH workspace restore.
What it means
Thrown during SSH workspace restore when `git merge-tree --write-tree` exited successfully but its stdout first line was empty, so no merged tree object id could be extracted. This is an unexpected git output shape: the command did not error but produced no usable tree id, so the subsequent commit-tree step cannot proceed.
Source
Thrown at packages/adapter-utils/src/ssh.ts:971
throw error;
}
}
let mergedTree;
try {
mergedTree = await runLocalGit(input.localDir, ["merge-tree", "--write-tree", currentHead, input.importedHead], {
timeout: 60_000,
maxBuffer: 256 * 1024,
});
} catch (error) {
const reason = error instanceof Error ? error.message : String(error);
throw new Error(
`Failed to merge concurrent SSH git histories for ${currentHead.slice(0, 12)} and ${input.importedHead.slice(0, 12)}: ${reason}`,
);
}
const mergedTreeId = mergedTree.stdout.trim().split("\n")[0]?.trim() ?? "";
if (!mergedTreeId) {
throw new Error("Failed to compute a merged git tree for SSH workspace restore.");
}
const mergeCommit = await runLocalGit(
input.localDir,
[
"commit-tree",
mergedTreeId,
"-p",
currentHead,
"-p",
input.importedHead,
"-m",
`Paperclip SSH sync merge ${input.importedHead.slice(0, 12)}`,
],
{
timeout: 60_000,
maxBuffer: 64 * 1024,
},View on GitHub (pinned to 67001ec6eb)
Solutions
- Check the installed git version matches Paperclip expectations (merge-tree --write-tree requires a modern git >= 2.38); upgrade git if old.
- Run the same merge-tree command manually in input.localDir and inspect raw stdout to see what the first line actually is.
- If currentHead and importedHead produce an empty merge-tree result, confirm both refs are valid non-empty commits.
- Report with the git version and raw stdout if the output shape is genuinely malformed.
Defensive patterns
Strategy: validation
Validate before calling
const out = await runLocalGit(localDir, ["merge-tree", "--write-tree", currentHead, importedHead]);
const treeId = out.stdout.trim().split("\n")[0]?.trim();
if (!treeId) {
throw new Error("merge-tree produced no tree id; check git version");
} Prevention
- Pin a modern git (>= 2.38) that supports merge-tree --write-tree with stable output.
- Unit-test the restore merge path against the deployed git version in CI.
- Surface the installed git version in diagnostics when this fires.
When it happens
Trigger: mergeConcurrentSshGitHistories runs merge-tree --write-tree successfully (no exception) but mergedTree.stdout.trim().split('\n')[0] is empty. Can happen with unusual git versions that emit a different first-line format, or when stdout is whitespace-only due to an upstream pipe/buffer issue.
Common situations: A git version mismatch on the host producing unexpected merge-tree output; an edge case where merge-tree writes a trailing-newline-only output for already-merged trees; an environment with a git alias or wrapper that mangles stdout.
Related errors
- Failed to merge concurrent SSH git histories for ${currentHe
- Failed to integrate concurrent SSH git history for ${input.i
- Invalid SSH environment variable key: ${key}
- Timed out waiting for workspace restore lock at ${lockDir}
- Managed git install metadata is incomplete.
AI-assisted analysis of paperclipai/paperclip@67001ec6eb (2026-08-12).
Data as JSON: /api/errors/88dcf84261821c7c.
Report an issue: GitHub.