diff --git a/integration/dockerfiles/Dockerfile_test_add_404 b/integration/dockerfiles/Dockerfile_test_add_404 new file mode 100644 index 000000000..21b31ae1f --- /dev/null +++ b/integration/dockerfiles/Dockerfile_test_add_404 @@ -0,0 +1,4 @@ +FROM debian:9.11 + +# Testing that any HTTP failure is handled properly +ADD https://httpstat.us/404 . diff --git a/pkg/util/fs_util.go b/pkg/util/fs_util.go index 9a34f2974..38c91357e 100644 --- a/pkg/util/fs_util.go +++ b/pkg/util/fs_util.go @@ -545,6 +545,11 @@ func DownloadFileToDest(rawurl, dest string, uid, gid int64) error { return err } defer resp.Body.Close() + + if resp.StatusCode >= 400 { + return fmt.Errorf("%s failed with %d", rawurl, resp.StatusCode) + } + if err := CreateFile(dest, resp.Body, 0600, uint32(uid), uint32(gid)); err != nil { return err }