diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-06-01 19:10:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-01 19:10:47 +0200 |
commit | 7a52440a6d7fe7ac1ddccf9fe7247d7abca8ecce (patch) | |
tree | 1793b64b9b457affd6683ba8db7185df713772c2 /pkg | |
parent | 19cd46cdc2a69cddfe4e3fce5b9859d4fe9b24a6 (diff) | |
parent | 3330f98762c809ef788be88bd15744834cff2535 (diff) | |
download | podman-7a52440a6d7fe7ac1ddccf9fe7247d7abca8ecce.tar.gz podman-7a52440a6d7fe7ac1ddccf9fe7247d7abca8ecce.tar.bz2 podman-7a52440a6d7fe7ac1ddccf9fe7247d7abca8ecce.zip |
Merge pull request #10508 from matejvasek/fix-from-img
Better error handing for images/create compat api
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/api/handlers/compat/images.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/pkg/api/handlers/compat/images.go b/pkg/api/handlers/compat/images.go index 58bf42442..7b336c470 100644 --- a/pkg/api/handlers/compat/images.go +++ b/pkg/api/handlers/compat/images.go @@ -12,6 +12,7 @@ import ( "github.com/containers/common/libimage" "github.com/containers/common/pkg/config" "github.com/containers/image/v5/manifest" + "github.com/containers/image/v5/pkg/shortnames" "github.com/containers/image/v5/types" "github.com/containers/podman/v3/libpod" "github.com/containers/podman/v3/pkg/api/handlers" @@ -234,6 +235,14 @@ func CreateImageFromImage(w http.ResponseWriter, r *http.Request) { fromImage := mergeNameAndTagOrDigest(query.FromImage, query.Tag) + // without this early check this function would return 200 but reported error via body stream soon after + // it's better to let caller know early via HTTP status code that request cannot be processed + _, err := shortnames.Resolve(runtime.SystemContext(), fromImage) + if err != nil { + utils.Error(w, "Something went wrong.", http.StatusBadRequest, errors.Wrap(err, "failed to resolve image name")) + return + } + authConf, authfile, key, err := auth.GetCredentials(r) if err != nil { utils.Error(w, "failed to retrieve repository credentials", http.StatusBadRequest, errors.Wrapf(err, "failed to parse %q header for %s", key, r.URL.String())) |