Skip to content

Raise errors reported in the stream from ImageCollection.pull - #3453

Open
thirtyseven wants to merge 1 commit into
docker:mainfrom
thirtyseven:images-pull-raise-stream-errors
Open

thirtyseven wants to merge 1 commit into
docker:mainfrom
thirtyseven:images-pull-raise-stream-errors

Conversation

@thirtyseven

Copy link
Copy Markdown

The daemon reports a failed pull inside the HTTP 200 response's JSON stream. ImageCollection.pull drains that stream without reading it and then inspects the image, so any failure after the request is accepted (a registry refusal, a failed layer extraction) surfaces as ImageNotFound for an image that exists. ContainerCollection.run falls back to pull and hides the cause the same way. Libraries built on it, such as testcontainers-python, inherit the misleading error.

This decodes the stream and raises a new ImagePullError with the daemon's message, the same way ImageCollection.load raises ImageLoadError.

Before and after, pulling while a concurrent docker image prune corrupts the pull (moby/moby#53321):

before: docker.errors.ImageNotFound: 404 Client Error … ("No such image: python:3.12.7")
after:  docker.errors.ImagePullError: failed to extract layer (…) to overlayfs as "extract-…": failed call to UtimesNanoAt …: no such file or directory

Callers that caught ImageNotFound around a failed pull will now see ImagePullError. Unit tests cover an errorDetail frame and a bare error frame.

🤖 Generated with Claude Code

The daemon reports a failed pull inside the 200 response's JSON stream,
not as an HTTP error. ImageCollection.pull drained that stream without
reading it, then looked the image up, so every such failure (a registry
refusal, a corrupted layer extraction) surfaced as ImageNotFound for an
image that does exist upstream. ContainerCollection.run falls back to
pull, so it hid the cause the same way.

Decode the stream and raise ImagePullError with the daemon's message,
mirroring how ImageCollection.load raises ImageLoadError.

Signed-off-by: Ted Kaplan <ted.kaplan@bedrockrobotics.com>
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.

1 participant