fix: expose apply-patch missing-file errors

This commit is contained in:
Codex
2026-06-02 02:35:51 +00:00
parent db8b1b64af
commit e95e1c044a
2 changed files with 35 additions and 9 deletions
+3 -1
View File
@@ -425,7 +425,7 @@ async function readRemoteText(executor: ApplyPatchV2Executor, target: string): P
const [bytesText, expectedSha256] = stat.stdout.trim().split(/\s+/u);
const expectedBytes = Number(bytesText);
if (!Number.isSafeInteger(expectedBytes) || expectedBytes < 0 || !/^[0-9a-f]{64}$/u.test(expectedSha256 ?? "")) {
throw new ApplyPatchV2Error("remote apply-patch v2 stat returned invalid metadata", { path: target, stdout: stat.stdout.slice(0, 500) });
throw new ApplyPatchV2Error("remote apply-patch v2 stat returned invalid metadata", { path: target, stdout: stat.stdout.slice(0, 500), stderr: stat.stderr.slice(-500) });
}
const chunks: Buffer[] = [];
@@ -606,6 +606,8 @@ function remoteV2Script(operation: RemoteV2Operation, args: string[]): string[]
"case \"$op\" in",
" stat)",
" target=$1",
" if [ ! -e \"$target\" ]; then printf 'file not found: %s\\n' \"$target\" >&2; exit 1; fi",
" if [ -d \"$target\" ]; then printf 'not a file: %s\\n' \"$target\" >&2; exit 1; fi",
" bytes=$(wc -c < \"$target\" | tr -d '[:space:]')",
" digest=$(sha256_file \"$target\")",
" printf '%s %s\\n' \"$bytes\" \"$digest\"",