Skip to content

chore: fix error in validating icon. Shows proper message #97

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 18, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions cmd/validate/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,27 +135,29 @@ func isIconValid(name string) error {
return err
}

if server.Image == "" {
return fmt.Errorf("image is not valid. It must be a valid image")
if server.About.Icon == "" {
fmt.Println("🛑 No icon found")
return nil
}
// fetch the image and check the size
resp, err := http.Get(server.About.Icon)
if err != nil {
return err
fmt.Println("🛑 Icon could not be fetched")
return nil
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
return fmt.Errorf("image is not valid. It must be a valid image")
return fmt.Errorf("icon is not valid. It must be a valid image")
}
if resp.ContentLength > 2*1024*1024 {
return fmt.Errorf("image is too large. It must be less than 2MB")
return fmt.Errorf("icon is too large. It must be less than 2MB")
}
img, format, err := image.DecodeConfig(resp.Body)
if err != nil {
return err
}
if format != "png" {
return fmt.Errorf("image is not a png. It must be a png")
return fmt.Errorf("icon is not a png. It must be a png")
}

if img.Width > 512 || img.Height > 512 {
Expand Down