Skip to content

Fix: re-raise original docker exception in Sandbox.start error handlers - #75

Open
laohuan12138 wants to merge 1 commit into
straylabs-ai:mainfrom
laohuan12138:fix/sandbox-image-not-found-reraise
Open

Fix: re-raise original docker exception in Sandbox.start error handlers#75
laohuan12138 wants to merge 1 commit into
straylabs-ai:mainfrom
laohuan12138:fix/sandbox-image-not-found-reraise

Conversation

@laohuan12138

Copy link
Copy Markdown

Fixes #74

Summary

Sandbox.start() re-raised docker errors by constructing a new exception without a message:

except ImageNotFound as exc:
    raise ImageNotFound from exc   # ImageNotFound() → APIError() → TypeError
except NotFound as exc:
    raise NotFound from exc

docker.errors.ImageNotFound/NotFound inherit APIError, whose __init__ requires message. The no-arg construction raises TypeError: APIError.__init__() missing 1 required positional argument: 'message', masking the real error — e.g. when xoxruns/sandboxed_kali is missing locally, the user sees this TypeError instead of ImageNotFound.

Change

Re-raise the original exception in both handlers:

except ImageNotFound as exc:
    logger.error("Image not found %s", container_image)
    raise exc
except NotFound as exc:
    logger.error("Docker error: %s", exc.explanation)
    raise exc

Verification

  • Pre-fix: TypeError: APIError.__init__() missing 1 required positional argument: 'message' reproduced with docker SDK 7.1.0 (both with real SDK and the exact class hierarchy).
  • Post-fix: the original docker.errors.ImageNotFound propagates with its explanation intact.
  • Live check: with the sandbox image pulled, the CLI no longer reports the sandbox-creation failure.

Note: full pytest suite not run here (dependencies not installed in this environment); the change is limited to the two exception-handler lines and does not alter normal flow.

@xoxruns

xoxruns commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Just saw you PR. Gonna check this out to try and reproduce the error ! thank you @laohuan12138

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sandbox.start() crashes with TypeError: APIError.__init__() missing 1 required positional argument: "message" when image is missing

2 participants