{"record":{"id":"64b47f9a698c3e38","repo":"paperclipai/paperclip","slug":"could-not-read-execution-target-git-context","errorCode":null,"errorMessage":"Could not read execution-target Git context","messagePattern":"Could not read execution-target Git context","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/adapter-utils/src/execution-target.ts","lineNumber":1655,"sourceCode":"    printf 'PAPERCLIP_RUNNER_NETWORK_ROOT\\0%s\\0' \"$parent/$(basename \"$file\")\"\n  fi\ndone\ncwd=$(pwd -P)\ntop=$(git rev-parse --show-toplevel 2>/dev/null) || top=\nif [ -n \"$top\" ] && [ \"$(cd \"$top\" && pwd -P)\" = \"$cwd\" ]; then\n  for kind in --git-common-dir --git-dir; do\n    root=$(git rev-parse --path-format=absolute \"$kind\" 2>/dev/null) || continue\n    root=$(cd \"$root\" && pwd -P) || continue\n    printf 'PAPERCLIP_GIT_METADATA_ROOT\\0%s\\0' \"$root\"\n  done\nfi\nprintf '\\0PAPERCLIP_GIT_CONTEXT_END\\0'\n`;\n    const result = await adapterExecutionTargetCommandRunner(remote).execute({\n      command: \"sh\", args: [\"-c\", probe, \"paperclip-git-context\", input.hostCredentials ? \"host\" : \"managed\"],\n      cwd: input.cwd, timeoutMs: 15_000,\n    });\n    if (result.exitCode !== 0) throw new Error(\"Could not read execution-target Git context\");\n    const payload = result.stdout.split(\"\\0PAPERCLIP_GIT_CONTEXT_V1\\0\")[1]?.split(\"\\0PAPERCLIP_GIT_CONTEXT_END\\0\")[0];\n    if (payload === undefined) throw new Error(\"Could not read execution-target Git context\");\n    discovered = {};\n    const records = payload.split(\"\\0\");\n    const roots: string[] = [];\n    const networkRoots: string[] = [];\n    for (let index = 0; index + 1 < records.length; index += 2) {\n      const key = records[index]!;\n      const value = records[index + 1]!;\n      if (key === \"PAPERCLIP_GIT_METADATA_ROOT\") roots.push(value);\n      else if (key === \"PAPERCLIP_RUNNER_NETWORK_ROOT\") networkRoots.push(value);\n      else discovered[key] = value;\n    }\n    discovered.PAPERCLIP_GIT_METADATA_ROOTS = JSON.stringify([...new Set(roots)]);\n    discovered.PAPERCLIP_RUNNER_NETWORK_ROOTS = JSON.stringify([...new Set(networkRoots)]);\n  } else {\n    const result = await promisify(execFile)(process.execPath, args, { cwd: input.cwd, timeout: 15_000, maxBuffer: 1024 * 1024 });\n    try { discovered = JSON.parse(result.stdout.split(\"\\0\")[1] ?? \"\"); }","sourceCodeStart":1637,"sourceCodeEnd":1673,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/packages/adapter-utils/src/execution-target.ts#L1637-L1673","documentation":"prepareGitHubExecutionEnvironment probes the execution-target's Git context by running a shell script that emits a payload delimited by NUL markers (PAPERCLIP_GIT_CONTEXT_V1 ... PAPERCLIP_GIT_CONTEXT_END). This error is thrown when the probe exits non-zero or the delimited payload is absent from stdout, meaning the target's Git state (roots, remotes, etc.) could not be discovered.","triggerScenarios":"Remote sh -c probe returns non-zero (git not installed, cwd missing/not a repo, permission issues); shell output lacks the NUL delimiters because a login banner or a different shell swallowed the printf output; probe times out upstream.","commonSituations":"Running against a directory that is not a Git work tree; remote host without git on PATH; shell profiles printing output that corrupts the framed payload; the managed/host credential mode arg altering script behavior unexpectedly.","solutions":["Confirm the target cwd is a valid Git repository on the remote (`git -C <cwd> status`)","Ensure git is installed and on PATH on the remote target","Run the probe command manually over SSH to inspect raw output and stray banners","Fix or bypass shell init files that emit output before the script runs"],"exampleFix":"// verify before invoking\nssh user@remote 'cd <cwd> && git rev-parse --is-inside-work-tree && git --version'\n// then retry the operation","handlingStrategy":"validation","validationCode":"const st = await runner.execute({ command: 'sh', args: ['-c', `cd ${cwd} && git rev-parse --is-inside-work-tree`], timeoutMs: 10000 });\nif (st.exitCode !== 0) throw new Error('target cwd is not a git work tree');","typeGuard":null,"tryCatchPattern":"try {\n  await prepareGitHubExecutionEnvironment(input);\n} catch (e) {\n  if (String(e.message).includes('Could not read execution-target Git context')) {\n    console.error('verify remote cwd is a git repo and git is installed');\n  } else throw e;\n}","preventionTips":["Confirm the remote cwd is a valid Git work tree before launching","Install git on all remote execution targets","Suppress stdout noise from remote shell profiles that can corrupt framed payloads","Test the probe script manually over SSH when onboarding a new target"],"tags":["git","remote-execution","ssh"],"backgroundTag":"git-command-failed","analyzedSha":"01ad8584922b5d85292b1723cae71fa0d9b07a19","analyzedAt":"2026-09-10T03:14:50.855Z","contentChangedAt":"2026-09-10T03:14:50.855Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}