can1357/oh-my-pi · error · Error
git apply with baseline WIP failed for task ${taskId}: ${std
Error message
git apply with baseline WIP failed for task ${taskId}: ${stderr} What it means
Final fallback in the patch-application ladder: after plain `git apply` and `git apply --3way` both fail, the code resets the worktree, seeds the parent's WIP as a baseline commit, and retries `git apply` against that baseline. If this baseline-WIP attempt also fails, it throws with the git stderr attached.
Source
Thrown at packages/coding-agent/src/task/worktree.ts:680
try {
// `git apply --3way` leaves conflict markers in `U` files when
// it can't resolve; reset the worktree so the WIP-seeded retry
// starts from a clean HEAD tree.
await repo.reset("hard", "HEAD");
await applyDeltaOverBaselineWip(tmpDir, taskId, patchText, wipPatches, baselineWip);
} catch (wipErr) {
if (!vcs.isVcsError(wipErr)) throw wipErr;
const stderr = wipErr.stderr.slice(0, 2000);
logger.error("commitToBranch: git apply with baseline WIP failed", {
taskId,
exitCode: wipErr.exitCode,
stderr,
threeWayStderr: threeWayErr.stderr.slice(0, 2000),
initialStderr: plainErr.stderr.slice(0, 2000),
patchSize: patchText.length,
patchHead: patchText.slice(0, 500),
});
throw new Error(`git apply with baseline WIP failed for task ${taskId}: ${stderr}`);
}
}
}
await repo.stageFiles([]);
await repo.commitCreate(message, author ? { author } : {});
}
/**
* Replay baseline WIP into the temp worktree so the delta patch's HEAD+WIP
* context matches, apply the delta, then rewind files WIP touched but the
* delta didn't — HEAD-tracked files are restored via `git restore`, untracked
* or staged-new WIP files are removed from the worktree. The commit that
* follows reflects agent's delta plus any overlap with WIP; parent's
* stash-pop reconciles the WIP side on merge-back.
*/
async function applyDeltaOverBaselineWip(
tmpDir: string,View on GitHub (pinned to 9690622007)
Solutions
- Inspect the embedded stderr; apply the task's diff manually with `git apply --reject` and resolve rejects
- Re-run the isolated task against the current parent HEAD so its patch is generated from fresh context
- Check git repository health (index.lock, fsck) and patch size limits (`git config http.postBuffer` irrelevant locally but core limits matter)
Defensive patterns
Strategy: try-catch
Validate before calling
const probe = await $`git apply --check patch.diff`.cwd(repoDir).quiet().nothrow();
if (probe.exitCode !== 0) {
// apply manually with --reject before attempting the automated ladder
} Try / catch
try {
await mergeTaskPatch(taskId, patchText);
} catch (err) {
if ((err as Error).message.startsWith("git apply with baseline WIP failed")) {
// fall back to `git apply --reject` and human conflict resolution
}
throw err;
} Prevention
- Re-run long-lived tasks against a fresh parent HEAD before merging
- Inspect patchHead/stderr diagnostics logged before the throw
- Check for index.lock or repo-health issues before automated merges
When it happens
Trigger: Calling the task-merge path when even applying against a WIP-seeded baseline fails: deeply diverged content, malformed patch, paths that no longer exist, or repository state issues (index locks, detached HEAD problems).
Common situations: Tasks touching files heavily refactored in the parent while the task ran; patches larger than git's size limits; corrupted or oversized patch payloads.
Related errors
- git apply --3way failed for task ${taskId}: ${stderr}
- merge conflict in {} file(s)
- not a repository: {path}
- reference not found: {name}
- object not found: {spec}
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/f0eef7bc01676607.
Report an issue: GitHub.