Skip to content

Make libpod return error status code on failure to pull image#28109

Merged
mheon merged 1 commit intocontainers:mainfrom
simonbrauner:issue-22105
Mar 9, 2026
Merged

Make libpod return error status code on failure to pull image#28109
mheon merged 1 commit intocontainers:mainfrom
simonbrauner:issue-22105

Conversation

@simonbrauner
Copy link
Contributor

@simonbrauner simonbrauner commented Feb 17, 2026

Checklist

Ensure you have completed the following checklist for your pull request to be reviewed:

  • Certify you wrote the patch or otherwise have the right to pass it on as an open-source patch by signing all
    commits. (git commit -s). (If needed, use git commit -s --amend). The author email must match
    the sign-off email address. See CONTRIBUTING.md
    for more information.
  • Referenced issues using Fixes: #00000 in commit message (if applicable)
  • Tests have been added/updated (or no tests are needed)
  • Documentation has been updated (or no documentation changes are needed)
  • All commits pass make validatepr (format/lint checks)
  • Release note entered in the section below (or None if no user-facing changes)

Does this PR introduce a user-facing change?

The API endpoint `/libpod/images/pull` returns an error status code on failure to pull image instead of always returning 200.

@github-actions github-actions bot added the kind/api-change Change to remote API; merits scrutiny label Feb 17, 2026
@packit-as-a-service
Copy link

[NON-BLOCKING] Packit jobs failed. @containers/packit-build please check. Everyone else, feel free to ignore.

Copy link
Contributor

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

I didn’t carefully re-read the full function, but at a glance, this looks pretty good.

(As discussed, we should probably start streaming after some timeout.)

@simonbrauner simonbrauner force-pushed the issue-22105 branch 9 times, most recently from e56c699 to cb866ac Compare February 18, 2026 14:53
@simonbrauner simonbrauner marked this pull request as ready for review February 18, 2026 15:01
@inknos inknos added the 6.0 Breaking changes for Podman 6.0 label Feb 18, 2026
Copy link
Member

@Honny1 Honny1 left a comment

Choose a reason for hiding this comment

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

My only comment is about the specific section that I believe is causing the CI to fail. This could be solved by either adapting the client to accept multiple reports in a single response or by just sending one report per response (less breaking change). Also, it should be documented that the response contains multiple JSON objects.

@simonbrauner simonbrauner force-pushed the issue-22105 branch 9 times, most recently from bd69b6b to 44cdac1 Compare February 23, 2026 12:32
@simonbrauner simonbrauner requested a review from Honny1 February 23, 2026 13:13
@simonbrauner
Copy link
Contributor Author

My only comment is about the specific section that I believe is causing the CI to fail. This could be solved by either adapting the client to accept multiple reports in a single response or by just sending one report per response (less breaking change). Also, it should be documented that the response contains multiple JSON objects.

It should be fixed now

Copy link
Member

@Honny1 Honny1 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

ACK overall, just a bunch of comments to simplify future maintenance.

But I’d like the formal LGTM to be from someone familiar with the swagger documentation / tooling.

images, err := runtime.LibimageRuntime().Pull(r.Context(), query.Reference, pullPolicy, pullOptions)
var report entities.ImagePullReport
if err != nil {
report.Error = err.Error()
Copy link
Contributor

Choose a reason for hiding this comment

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

I suppose this is technically an API break. API experts, is that OK?

Copy link
Member

Choose a reason for hiding this comment

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

With 6.0, yes, I am fine with this sort of thing.

flush()
case <-runCtx.Done():
if !streamingStarted && pullError != nil {
utils.Error(w, utils.HTTPStatusFromRegistryError(pullError), pullError)
Copy link
Contributor

Choose a reason for hiding this comment

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

I suppose this is technically an API break. API experts, is that OK?

Copy link
Collaborator

Choose a reason for hiding this comment

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

that is API break, marking it with label 6.0 should be it to track it, just double triple checking @Luap99 @mheon ?

Copy link
Member

Choose a reason for hiding this comment

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

I think that should be fine. AFAICT the podman-remote client should be able to handle that error at least and generally speaking all clients should handle any http status error already as well as it could have failed for other reasons so I would consider this a bug fix

@simonbrauner
Copy link
Contributor Author

@mtrmac I addressed your comments, except for those about API break

Copy link
Contributor

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

ACK, still

I’d like the formal LGTM to be from someone familiar with the swagger documentation / tooling.

simonbrauner added a commit to simonbrauner/podman-py that referenced this pull request Mar 4, 2026
Podman part of the functionality implemented in
containers/podman#28109

Fixes: containers#301

Signed-off-by: Šimon Brauner <sbrauner@redhat.com>
// - images
// summary: Pull images
// description: Pull one or more images from a container registry.
// description: Pull one or more images from a container registry. Error status codes can come either from the API or from the registry.
Copy link
Member

Choose a reason for hiding this comment

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

I would also inform users that if an error occurs mid-pull, the HTTP status code will be 200, and the error will be detailed in the report's error field.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is in the description of the response now, do you think it would be better to move it to the main description?
Screenshot From 2026-03-04 13-49-23

Copy link
Member

Choose a reason for hiding this comment

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

I would put that in both places, or just not mention the error codes in the description at all, since it currently only covers one potential error path.

I think it's obvious from the error codes that 401, 403, and 404 are from the repository, not errors caused by the Podman pulling logic. Maybe this could be stated more clearly in the description of each error code.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's obvious from the error codes that 401, 403, and 404 are from the repository

The difficulty here is that pull registry.example/nonexistentrepo reports 404 in some registries, and 401 in others (under the theory that there might be a private repo that the user is not allowed to see, and returning 404 would disclose that information — so always returning 401 is more secure).

Copy link
Member

Choose a reason for hiding this comment

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

I think instead of listing every possible error code, we could use a wildcard to indicate that any other error codes returned by the repository will be propagated to the client.

For example:

responses:
  '200':
    description: OK
  '400':
    description: Bad Request (explicitly handled)
  default:
    description: Unexpected Error (This propagates any other repository errors)
    content:
      application/json:
        schema:
          $ref: '#/components/schemas/ErrorModel'

Copy link
Contributor

Choose a reason for hiding this comment

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

I think, ideally, we would add registry-specific heuristics (where possible, sometimes registries intentionally hide information) and allow ~reliable detection of “repository is missing” and other error kinds. In that sense, promising to propagate raw registry status is not ideal either.

Pragmatically, I’m not sure how much that matters, because the HTTP statuses (and even more registry error codes) are simply unreliable across the registry ecosystem; so users need to rely on integration tests anyway, regardless of what we document.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is the version with default now, is that fine? or would it better to switch back to the explicit 401/403/404?

simonbrauner added a commit to simonbrauner/podman-py that referenced this pull request Mar 4, 2026
Podman part of the functionality implemented in
containers/podman#28109

Fixes: containers#301

Signed-off-by: Šimon Brauner <sbrauner@redhat.com>
simonbrauner added a commit to simonbrauner/podman-py that referenced this pull request Mar 4, 2026
Podman part of the functionality implemented in
containers/podman#28109

Fixes: containers#301

Signed-off-by: Šimon Brauner <sbrauner@redhat.com>
simonbrauner added a commit to simonbrauner/podman-py that referenced this pull request Mar 4, 2026
Podman part of the functionality implemented in
containers/podman#28109

Fixes: containers#301

Signed-off-by: Šimon Brauner <sbrauner@redhat.com>
simonbrauner added a commit to simonbrauner/podman-py that referenced this pull request Mar 5, 2026
Podman part of the functionality implemented in
containers/podman#28109

Fixes: containers#301

Signed-off-by: Šimon Brauner <sbrauner@redhat.com>
Copy link
Member

@Honny1 Honny1 left a comment

Choose a reason for hiding this comment

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

LGTM

@Honny1
Copy link
Member

Honny1 commented Mar 9, 2026

LGTM,

PTAL @containers/podman-maintainers final review and merge.

Fixes: containers#22105

Signed-off-by: Šimon Brauner <sbrauner@redhat.com>
@mheon
Copy link
Member

mheon commented Mar 9, 2026

LGTM

@mheon mheon merged commit 6b10bea into containers:main Mar 9, 2026
78 of 82 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.0 Breaking changes for Podman 6.0 kind/api-change Change to remote API; merits scrutiny

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants