diff --git a/types/errors.go b/types/errors.go index d42e2a77..8ffef932 100644 --- a/types/errors.go +++ b/types/errors.go @@ -19,6 +19,7 @@ var ( ErrInvalidUrlLength = errors.New("url length should be no larger than 1024 character") ErrInvalidUrl = errors.New("invalid url") + ErrImageFetchFailed = errors.New("error fetching operator logo") ErrInvalidImageMimeType = errors.New("invalid image mime-type. only png is supported") ErrInvalidImageExtension = errors.New( "invalid image extension. only " + strings.Join(ImageExtensions, ",") + " is supported", diff --git a/types/operator_metadata.go b/types/operator_metadata.go index 1b2889b0..1ea1bd9f 100644 --- a/types/operator_metadata.go +++ b/types/operator_metadata.go @@ -139,6 +139,12 @@ func isImageURL(urlString string) error { if err != nil { return err } + + // Check if the response status was an error + if imageResponse.StatusCode >= 400 { + return ErrImageFetchFailed + } + imageBytes, err := io.ReadAll(imageResponse.Body) if err != nil { return err