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 <noreply@paperclip.ing>
This commit is contained in:
Devin FoleyandPaperclip committed 2026-11-12 19:49:10 -08:00
1 parent 0631cf1ec3
commit c3fbe23431
2 files changed
+9 -7

No files matched your search

@@ -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);
@@ -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;