You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feature: Add proper error reporting for inspect #2589
Thanks for reaching out. Please be more specific in what you mean by “proper”.
Are you talking about exit codes only? And, if relevant, what conditions?
(Ultimately, there’s very little that can fit into an 8-bit field. At some point, it would be easier to write a Go program a receive full Go types directly … to the extent those make any promises about reported error types, which is also somewhat limited.)
The current exit status 2 is documented in skopeo(1). But note the caveat there; there is no way to reliably distinguish an authentication failure from a missing image, in general. Some things just aren’t possible.
Ah ok, jeah I mean only exit code: so you say the container registry API does not have a destinction in http response status codes between notfound and auth error? Strange?
especially for the transport docker://
It does have that distinction, but there have been registries which replied with “not found” to requests to read something the user (anonymous or authenticated) does not have the right to to access — I guess with the idea that even disclosing the existence of that name is disclosing private information.
Ah, ok. Its just hard to know what maps to 2? Possibly anything? Also server error? Or only failures of Unauthorized/Notfound etc for that Inspect operations?
It just leads to code like this, but maybe there is no better way?
funccheckIfExists(skopeo*skopeo.Context, deststring) (existsbool, errerror) {
log.Info("Checking if image already exists.")
cmd:= []string{"inspect"}
cmd=append(cmd, dest)
exists=true// When repository does not exist yet ->// we get exit code 1, an we need to handle it somehow.// The workaround below is really ugly and prone to break!resp, e:=skopeo.GetCombinedWithEC(
func(cmdError*exec.CmdError) error {
ifcmdError!=nil&&cmdError.ExitCode() ==2 {
exists=falsereturnnil
}
returncmdError
},
cmd...)
ife!=nil {
ifstrings.Contains(resp, "invalid status code from registry 403") ||strings.Contains(resp, "requested access to the resource is denied") {
// we have 403 which is ok, the registry does not yet exist.exists=false
}
returntrue, errors.AddContext(
e,
"could not check if image '%s' exists:\nstdout/err:\n%s",
dest,
resp,
)
}
returnexists, nil
}
I’d expect the behavior to be stable for a given server (and server’s software version?). But writing a tool reliably working for any registry on the internet is difficult.
(To be explicit, nothing in Skopeo promises to continue to use the exact text invalid status code from registry 403 in error messages, and we did change error texts in the past.)
@mtrmac : Jeah thats correct, its a dumb workaround =). I now understand that its kind of difficult to make it work in all cases. The tool is great though!
As an example of the difficulty of doing something useful here, recently I have noticed:
% skopeo inspect docker://quay.io/libpod/alpine:nonexistenttagFATA[0001] Error parsing image name "docker://quay.io/libpod/alpine:nonexistenttag": reading manifest nonexistenttag in quay.io/libpod/alpine: manifest unknown
% skopeo inspect docker://quay.io/libpod/nonexistentrepo FATA[0001] Error parsing image name "docker://quay.io/libpod/nonexistentrepo": reading manifest latest in quay.io/libpod/nonexistentrepo: unauthorized: access to the requested resource is not authorized
Revisiting this a bit — I don’t think there’s much that makes sense to try to fit into the exit status. We certainly can’t fit all possible HTTP statuses there :)
For the provided example, which is trying to check whether an image “exists”, that’s already supposed to be exit status 2 — but with all the limitations and issues noted above. (I don’t think it’s at reasonable in general to treat HTTP 403 as “image does not exist”).
If we manage to improve the “image does not exist” heuristics, that would continue to use exit status 2.
But, noting that the caller is Go: use go.podman.io/image/v5 directly, and that gets quite a bit more granularity. By no means full granularity, quite a few of the error types are private, but there’s much more that can be done at that level.
Activity
mtrmac commentedon Apr 30, 2025
Thanks for reaching out. Please be more specific in what you mean by “proper”.
Are you talking about exit codes only? And, if relevant, what conditions?
(Ultimately, there’s very little that can fit into an 8-bit field. At some point, it would be easier to write a Go program a receive full Go types directly … to the extent those make any promises about reported error types, which is also somewhat limited.)
The current exit status 2 is documented in
skopeo(1). But note the caveat there; there is no way to reliably distinguish an authentication failure from a missing image, in general. Some things just aren’t possible.gabyx commentedon May 3, 2025
Ah ok, jeah I mean only exit code: so you say the container registry API does not have a destinction in http response status codes between notfound and auth error? Strange?
especially for the transport docker://
mtrmac commentedon May 5, 2025
It does have that distinction, but there have been registries which replied with “not found” to requests to read something the user (anonymous or authenticated) does not have the right to to access — I guess with the idea that even disclosing the existence of that name is disclosing private information.
gabyx commentedon May 5, 2025
Ah, ok. Its just hard to know what maps to 2? Possibly anything? Also server error? Or only failures of Unauthorized/Notfound etc for that Inspect operations?
It just leads to code like this, but maybe there is no better way?
mtrmac commentedon May 5, 2025
I’d expect the behavior to be stable for a given server (and server’s software version?). But writing a tool reliably working for any registry on the internet is difficult.
(To be explicit, nothing in Skopeo promises to continue to use the exact text
invalid status code from registry 403in error messages, and we did change error texts in the past.)gabyx commentedon May 5, 2025
@mtrmac : Jeah thats correct, its a dumb workaround =). I now understand that its kind of difficult to make it work in all cases. The tool is great though!
mtrmac commentedon May 28, 2025
As an example of the difficulty of doing something useful here, recently I have noticed:
github-actions commentedon Jun 28, 2025
A friendly reminder that this issue had no activity for 30 days.
mtrmac commentedon Mar 24, 2026
Revisiting this a bit — I don’t think there’s much that makes sense to try to fit into the exit status. We certainly can’t fit all possible HTTP statuses there :)
For the provided example, which is trying to check whether an image “exists”, that’s already supposed to be exit status 2 — but with all the limitations and issues noted above. (I don’t think it’s at reasonable in general to treat HTTP 403 as “image does not exist”).
If we manage to improve the “image does not exist” heuristics, that would continue to use exit status 2.
But, noting that the caller is Go: use
go.podman.io/image/v5directly, and that gets quite a bit more granularity. By no means full granularity, quite a few of the error types are private, but there’s much more that can be done at that level.