fix(sandbox): improve docker image existence check error handling

Previously, `dockerImageExists` assumed any error from `docker image inspect` meant the image did not exist. This masked other errors like socket permission issues.

This change:
- Modifies `dockerImageExists` to inspect stderr when the exit code is non-zero.
- Returns `false` only if the error explicitly indicates "No such image" or "No such object".
- Throws an error with the stderr content for all other failures.
- Adds a reproduction test in `src/agents/sandbox/docker.test.ts`.
This commit is contained in:
google-labs-jules[bot]
2026-01-23 22:15:33 +00:00
committed by Peter Steinberger
parent 86db180a17
commit 49c6d8019f
2 changed files with 54 additions and 1 deletions

View File

@@ -50,7 +50,16 @@ async function dockerImageExists(image: string) {
const result = await execDocker(["image", "inspect", image], {
allowFailure: true,
});
return result.code === 0;
if (result.code === 0) return true;
const stderr = result.stderr.trim();
if (
stderr.includes("No such image") ||
stderr.includes("No such object") ||
stderr.includes("not found")
) {
return false;
}
throw new Error(`Failed to inspect sandbox image: ${stderr}`);
}
export async function ensureDockerImage(image: string) {