{"record":{"id":"90ea003092fdd09f","repo":"paperclipai/paperclip","slug":"workspace-restore-left-staged-git-index-changes-af","errorCode":null,"errorMessage":"Workspace restore left staged git index changes after reset:\\n${stagedDiff.stdout.trim()}","messagePattern":"Workspace restore left staged git index changes after reset:\\\\n(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/adapter-utils/src/git-workspace-sync.ts","lineNumber":626,"sourceCode":"      maxBuffer: 1024 * 1024,\n    });\n  } catch (error) {\n    const detail = error && typeof error === \"object\"\n      ? [\n        (error as { message?: unknown }).message,\n        (error as { stderr?: unknown }).stderr,\n        (error as { stdout?: unknown }).stdout,\n      ].filter((value): value is string => typeof value === \"string\" && value.trim().length > 0).join(\"\\n\")\n      : String(error);\n    throw new Error(`Failed to reset local git index to HEAD after workspace restore: ${detail}`);\n  }\n\n  const stagedDiff = await runLocalGit(input.localDir, [\"diff\", \"--cached\", \"--name-status\", \"HEAD\", \"--\"], {\n    timeout: 10_000,\n    maxBuffer: 1024 * 1024,\n  });\n  if (stagedDiff.stdout.trim().length > 0) {\n    throw new Error(\n      `Workspace restore left staged git index changes after reset:\\n${stagedDiff.stdout.trim()}`,\n    );\n  }\n\n  if (!input.checkWorkingTreeClean) return;\n\n  const workingTreeDiff = await runLocalGit(input.localDir, [\"diff\", \"--name-status\", \"HEAD\", \"--\"], {\n    timeout: 10_000,\n    maxBuffer: 1024 * 1024,\n  });\n  if (workingTreeDiff.stdout.trim().length > 0) {\n    console.warn(\n      \"[paperclip] Workspace restore preserved local working tree changes after clean sandbox restore.\",\n    );\n  }\n}\n","sourceCodeStart":608,"sourceCodeEnd":643,"githubUrl":"https://github.com/paperclipai/paperclip/blob/120ae5428fa29bee300bcf806491cd4d965fbb7c/packages/adapter-utils/src/git-workspace-sync.ts#L608-L643","documentation":"After resetting the index, 'git diff --cached' still reports staged changes, so the restore left the index dirty relative to HEAD; a post-condition consistency guard.","triggerScenarios":"Thrown at packages/adapter-utils/src/git-workspace-sync.ts:626 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Run `git reset` in the workspace to unstage the listed changes, then retry the restore."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"120ae5428fa29bee300bcf806491cd4d965fbb7c","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}