fix: auto-pull image in run() when Podman returns 500 'image not known'#643
fix: auto-pull image in run() when Podman returns 500 'image not known'#643rahulkini31 wants to merge 1 commit intocontainers:mainfrom
Conversation
|
@rahulkini31 |
| except (ImageNotFound, APIError) as e: | ||
| if isinstance(e, APIError) and "image not known" not in str(e): | ||
| raise |
There was a problem hiding this comment.
I don't understand this code. here you are ignoring all the ApiErrors, unless they contain "image not known". would you help me understand what's the goal?
There was a problem hiding this comment.
Thanks for reviewing so quickly. Podman returns HTTP 500 (not 404) when an image is missing locally, so raise_for_status raises APIError instead of ImageNotFound. The original 'ImageNotFound' block never fired in this case. I've refactored to use separate except clauses with a comment explaining why APIError needs to be handled — hopefully clearer now. The mypy failure in utils.py is pre-existing and unrelated to this change.
When an image is not present locally, Podman returns HTTP 500 with "image not known" rather than HTTP 404. This caused run() to raise APIError instead of triggering the existing ImageNotFound catch block, so the auto-pull never happened. Extend the except clause to also catch APIError, re-raising it unless the message indicates a missing image. Add a unit test covering this path. Closes containers#594 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: rahulkini31 <rahulkini369@gmail.com>
73a068c to
9f6595b
Compare
|
@rahulkini31 this one needs a rebase |
When an image is not present locally, Podman returns HTTP 500 with "image not known" rather than HTTP 404. This caused run() to raise APIError instead of triggering the existing ImageNotFound catch block, so the auto-pull never happened.
Extend the except clause to also catch APIError, re-raising it unless the message indicates a missing image. Add a unit test covering this path.
Closes #594