{"record":{"id":"d1f925ae667c2716","repo":"paperclipai/paperclip","slug":"failed-to-reset-local-git-index-to-head-after-work","errorCode":null,"errorMessage":"Failed to reset local git index to HEAD after workspace restore: ${detail}","messagePattern":"Failed to reset local git index to HEAD after workspace restore: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/adapter-utils/src/git-workspace-sync.ts","lineNumber":682,"sourceCode":" * sandbox rather than discarding the run.\n */\nexport function isMissingGitPrerequisiteError(error: unknown): boolean {\n  const message = error instanceof Error ? error.message : String(error);\n  return GIT_MISSING_PREREQUISITE_MARKERS.some((marker) => message.includes(marker));\n}\n\nexport function buildRemoteGitDeltaBundleScript(input: {\n  remoteDir: string;\n  baseSha: string;\n  exportRef: string;\n  bundlePath: string;\n  statusPath?: string;\n  catBundle?: boolean;\n  cleanupBundle?: boolean;\n  /**\n   * Skip the delta boundary entirely and always emit a full, self-contained\n   * bundle (no prerequisites). Used as the recovery path when a delta import\n   * failed because the host lacked the bundle's prerequisite.\n   */\n  forceFullBundle?: boolean;\n}): string {\n  const remoteDir = shellQuote(input.remoteDir);\n  const bundlePath = shellQuote(input.bundlePath);\n  const exportRef = shellQuote(input.exportRef);\n  const baseSha = shellQuote(input.baseSha);\n  const statusPath = input.statusPath ? shellQuote(input.statusPath) : null;\n  const cleanupParts = [\n    `rm -f ${bundlePath}`,\n    ...(statusPath ? [`rm -f ${statusPath}`] : []),\n    `git -C ${remoteDir} update-ref -d ${exportRef} >/dev/null 2>&1 || true`,\n  ];\n  return [\n    \"set -e\",\n    input.cleanupBundle ? `cleanup() { ${cleanupParts.join(\"; \")}; }` : \"\",\n    input.cleanupBundle ? \"trap cleanup EXIT\" : \"\",\n    `mkdir -p ${shellQuote(path.posix.dirname(input.bundlePath))}`,","sourceCodeStart":664,"sourceCodeEnd":700,"githubUrl":"https://github.com/paperclipai/paperclip/blob/3f1d897a7c018d76563a21c6e39c3c9b03933622/packages/adapter-utils/src/git-workspace-sync.ts#L664-L700","documentation":"resetLocalGitIndexToHead's 'git reset HEAD -- .' failed after workspace restore; message/stderr details are attached so the index state can be diagnosed.","triggerScenarios":"Thrown at packages/adapter-utils/src/git-workspace-sync.ts:618 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the detail and fix the git index state manually (`git reset`), then retry."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3f1d897a7c018d76563a21c6e39c3c9b03933622","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}