Skip to content

fix: auto-pull image in run() when Podman returns 500 'image not known'#643

Open
rahulkini31 wants to merge 1 commit intocontainers:mainfrom
rahulkini31:fix/run-auto-pull-on-api-error
Open

fix: auto-pull image in run() when Podman returns 500 'image not known'#643
rahulkini31 wants to merge 1 commit intocontainers:mainfrom
rahulkini31:fix/run-auto-pull-on-api-error

Conversation

@rahulkini31
Copy link
Copy Markdown

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

@inknos
Copy link
Copy Markdown
Contributor

inknos commented Apr 9, 2026

@rahulkini31
thanks for the pr. please, add your signature to the commit with git commit -s. Also, address pre-commit. Happy to help with questions.

Comment thread podman/domain/containers_run.py Outdated
Comment on lines +77 to +79
except (ImageNotFound, APIError) as e:
if isinstance(e, APIError) and "image not known" not in str(e):
raise
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@rahulkini31 rahulkini31 force-pushed the fix/run-auto-pull-on-api-error branch from 73a068c to 9f6595b Compare April 9, 2026 14:43
@TomSweeneyRedHat
Copy link
Copy Markdown
Member

@rahulkini31 this one needs a rebase

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.

[BUG] run doesn't pull image automatically

3 participants