TypeScript
fix(provider-acp): name the rejected agent path on stderr and test the bash path (#18489)
Victor Vogel1d1a8e5b0714
diff --git a/apps/server/src/provider/acp/AcpSessionRuntime.processTree.test.ts b/apps/server/src/provider/acp/AcpSessionRuntime.processTree.test.tsindex e69401eaabf..cc911f2c60d 100644--- a/apps/server/src/provider/acp/AcpSessionRuntime.processTree.test.ts+++ b/apps/server/src/provider/acp/AcpSessionRuntime.processTree.test.ts@@ -306,6 +306,15 @@ describe("terminatePosixOwnedProcessTree", () => {},);expect(missingTargetResult.status, missingTargetResult.stderr).toBe(125);+ // CI's /bin/sh is dash, which runs the EXIT trap after a failed exec. Bash does not,+ // so run the same wrapper under bash too.+ const missingTargetBash = NodeChildProcess.spawnSync("bash", missingTarget.args, {+ encoding: "utf8",+ });+ if ((missingTargetBash.error as NodeJS.ErrnoException | undefined)?.code !== "ENOENT") {+ expect(missingTargetBash.status, missingTargetBash.stderr).toBe(125);+ expect(missingTargetBash.stderr).toContain("/nonexistent-t3-probe");+ }} finally {packagedExecPath.mockRestore();NodeFS.rmSync(scratch, { recursive: true, force: true });diff --git a/packages/provider-acp/src/server/AcpSessionRuntime.ts b/packages/provider-acp/src/server/AcpSessionRuntime.tsindex f0ff217a3a8..8f40efd164f 100644--- a/packages/provider-acp/src/server/AcpSessionRuntime.ts+++ b/packages/provider-acp/src/server/AcpSessionRuntime.ts@@ -284,8 +284,9 @@ export function wrapCommandForLinuxCgroup(// trap, so a missing agent binary reported "killed by the wrapper"// instead of "never launched". The caller always hands us an absolute// target, so test it as an executable file rather than asking the- // shell to resolve it.- '[ -f "$1" ] && [ -x "$1" ] || exit 125',+ // shell to resolve it. Name the target before exiting: exit 125 alone+ // does not say which path was rejected.+ '[ -f "$1" ] && [ -x "$1" ] || { printf "%s: %s: not an executable file\\n" "$0" "$1" >&2; exit 125; }','exec "$@"',].join("\n"),"t3-acp-cgroup-wrapper",