From c3fbe2343111ce35d8d90273d2de8140c607e5b2 Mon Sep 17 00:00:00 2001 From: Devin Foley Date: Thu, 12 Nov 2026 19:49:10 -0800 Subject: [PATCH] Keep SSH file-read status separate from connection warnings Send the missing-file marker on stdout so SSH host-key warnings on stderr do not invalidate a confirmed absence. Continue requiring the matching numeric exit status, and preserve all unrelated errors. Added a failing real-shell warning regression, then verified 60 affected runtime, credential, probe, and execution tests. Adapter-utils and Codex typechecks passed. Co-Authored-By: Paperclip --- .../adapter-utils/src/remote-managed-runtime.test.ts | 10 ++++++---- packages/adapter-utils/src/remote-managed-runtime.ts | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/adapter-utils/src/remote-managed-runtime.test.ts b/packages/adapter-utils/src/remote-managed-runtime.test.ts index d2850d865c3..ef64f3ac117 100644 --- a/packages/adapter-utils/src/remote-managed-runtime.test.ts +++ b/packages/adapter-utils/src/remote-managed-runtime.test.ts @@ -184,7 +184,7 @@ describe("remote managed runtime", () => { expect(restoredAuth).toBe('{"token":"remote"}\n'); }); - it.each(["missing", "present", "read failure", "connection failure"])( + it.each(["missing", "missing with SSH warning", "present", "read failure", "connection failure"])( "preserves SSH file-read error semantics for %s files", async outcome => { const root = await mkdtemp(path.join(os.tmpdir(), "paperclip-ssh-file-read-")); @@ -193,13 +193,15 @@ describe("remote managed runtime", () => { const assetDir = path.join(remoteCwd, ".paperclip-runtime", "codex", "home"); await mkdir(assetDir, { recursive: true }); const content = Buffer.from([0, 255, 1, 10]); - if (outcome !== "missing") await writeFile(path.join(assetDir, "auth.json"), content); + if (!outcome.startsWith("missing")) await writeFile(path.join(assetDir, "auth.json"), content); const transportError = Object.assign(new Error("fixture SSH connection failed"), { code: 255 }); runSshCommand.mockImplementationOnce(async (_spec, command) => { if (outcome === "connection failure") throw transportError; const script = outcome === "read failure" ? `base64() { printf '%s\\n' 'fixture read failure' >&2; return 44; }; ${command}` - : command!; + : outcome === "missing with SSH warning" + ? `printf '%s\\n' 'fixture SSH host-key warning' >&2; ${command}` + : command!; return promisify(execFile)("sh", ["-c", script!]); }); let bytes: Buffer | undefined; @@ -215,7 +217,7 @@ describe("remote managed runtime", () => { if (outcome === "present") { await prepared.restoreWorkspace(); expect(bytes).toEqual(content); - } else if (outcome === "missing") { + } else if (outcome.startsWith("missing")) { await expect(prepared.restoreWorkspace()).rejects.toMatchObject({ code: "ENOENT" }); } else if (outcome === "connection failure") { await expect(prepared.restoreWorkspace()).rejects.toBe(transportError); diff --git a/packages/adapter-utils/src/remote-managed-runtime.ts b/packages/adapter-utils/src/remote-managed-runtime.ts index c59b2a100e2..c31e911441a 100644 --- a/packages/adapter-utils/src/remote-managed-runtime.ts +++ b/packages/adapter-utils/src/remote-managed-runtime.ts @@ -81,13 +81,13 @@ async function readRemoteFile(spec: SshRemoteExecutionSpec, remotePath: string): const file = shellQuote(remotePath); const parent = shellQuote(path.posix.dirname(remotePath)); /* Confirm the parent is searchable so a permission error cannot masquerade as absence. */ - const command = `if [ -d ${parent} ] && [ -x ${parent} ] && [ ! -e ${file} ]; then printf '%s\\n' '${missingMarker}' >&2; exit ${missingExitCode}; fi; base64 < ${file}`; + const command = `if [ -d ${parent} ] && [ -x ${parent} ] && [ ! -e ${file} ]; then printf '%s\\n' '${missingMarker}'; exit ${missingExitCode}; fi; base64 < ${file}`; try { const result = await runSshCommand(spec, command, { maxBuffer: 1024 * 1024 }); return Buffer.from(result.stdout.replace(/\s+/g, ""), "base64"); } catch (error) { - const failure = error as { code?: unknown; stderr?: unknown } | null; - if (failure?.code === missingExitCode && typeof failure.stderr === "string" && failure.stderr.trim() === missingMarker) { + const failure = error as { code?: unknown; stdout?: unknown } | null; + if (failure?.code === missingExitCode && typeof failure.stdout === "string" && failure.stdout.trim() === missingMarker) { throw Object.assign(new Error("Remote runtime file does not exist"), { code: "ENOENT" }); } throw error;