mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 08:37:41 +00:00
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:
committed by
Peter Steinberger
parent
86db180a17
commit
49c6d8019f
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user