HazAT / badge

Add a badge to your app icon
MIT License
966 stars 87 forks source link

Error loading image from shields.io response Error #111

Open mistdon opened 3 years ago

mistdon commented 3 years ago

Cannot download svg image because of 403 [Forbidden]

DEBUG [2021-07-20 17:03:45.44]: Verbose active... VERSION: 0.13.0 DEBUG [2021-07-20 17:03:45.44]: Parameters: {:shield=>"--orange", :dark=>true, :alpha=>nil, :alpha_channel=>nil, :custom=>nil, :no_badge=>nil, :badge_gravity=>nil, :shield_parameters=>nil, :shield_io_timeout=>nil, :shield_geometry=>nil, :shield_gravity=>nil, :shield_scale=>nil, :shield_no_resize=>nil, :glob=>nil, :grayscale=>false} INFO [2021-07-20 17:03:45.44]: Start adding badges... DEBUG [2021-07-20 17:03:45.44]: Trying to load image from shields.io. Timeout: 10s DEBUG [2021-07-20 17:03:45.44]: URL: https://img.shields.io/badge/--orange.svg ERROR [2021-07-20 17:03:45.67]: Error loading image from shields.io response Error. Use --verbose for more info DEBUG [2021-07-20 17:03:45.67]: ["403", "Forbidden"] INFO [2021-07-20 17:03:45.67]: Waiting for 10s and retry to load image from shields.io tries remaining: 10

amityadav12239 commented 3 years ago

I am also facing the same issue. Why does it complain and how to fix it is not clear. Please suggest.

howlingblast commented 3 years ago

I can confirm the issue. I tried calling badge directly from the command line and it worked without timeout. Started from fastlane it will yield above error and retry every 10s for 10 times.

Tayphoon commented 2 years ago

+

badgeek commented 2 years ago

I can confirm the issue. I tried calling badge directly from the command line and it worked without timeout. Started from fastlane it will yield above error and retry every 10s for 10 times.

i can confirm this

nvx commented 2 years ago

Looking at the SVG output from shields.io, surely it wouldn't be hard to replace shields.io with locally generated SVGs which would increase the reliability of this immensely.

Alternatively being able to point to a different server where you could implement your own equivalent functionality. At the moment it looks like the shields.io domain is hardcoded.

@HazAT Would you be interested in either of these options?

HazAT commented 2 years ago

@nvx I mean locally would be better, maybe as a fallback. Not sure tho how much work it is 😅 Pointing to another server sounds cool but in reality, who has something like this?

nvx commented 2 years ago

@nvx I mean locally would be better, maybe as a fallback. Not sure tho how much work it is 😅 Pointing to another server sounds cool but in reality, who has something like this?

I mean the shields.io code is open source, they've even got a guide on hosting your own: https://github.com/badges/shields/blob/master/doc/self-hosting.md

At least personally I'm already running Jenkins with multiple build slaves, running a local shields server in a docker container wouldn't be hard, especially if not running the raster server component.

master-lincoln commented 2 years ago

I was experiencing the same issue on a MacOS Jenkins build machine and found it's because an IPv6 address is resolved for the host which does not answer:

$ wget -6 -v --timeout=10 --tries=1 https://img.shields.io/badge/feature-1.71.18-purple.svg
--2022-09-27 21:35:04--  https://img.shields.io/badge/feature-1.71.18-purple.svg
Loaded CA certificate '/etc/ssl/certs/ca-certificates.crt'
Resolving img.shields.io (img.shields.io)... 2606:4700:e4::ac40:ae10, 2606:4700:e4::ac40:af10
Connecting to img.shields.io (img.shields.io)|2606:4700:e4::ac40:ae10|:443... failed: Connection timed out.
Connecting to img.shields.io (img.shields.io)|2606:4700:e4::ac40:af10|:443... failed: Connection timed out.
Giving up.

Using the IPv4 address worked:

wget -4 -v https://img.shields.io/badge/feature-1.71.18-purple.svg
--2022-09-27 21:05:10--  https://img.shields.io/badge/feature-1.71.18-purple.svg
Resolving img.shields.io (img.shields.io)... 172.64.174.16, 172.64.175.16
Connecting to img.shields.io (img.shields.io)|172.64.174.16|:443... connected.
...

I was trying this from 2 different networks, so it seems the server of img.shields.io is not answering on port 443 for neither of the resolved IPv6 IPs 2606:4700:e4::ac40:ae10 or 2606:4700:e4::ac40:af10. @HazAT can you confirm this?

Self hosting would be easier for us if an option was added to configure the urls

pke commented 2 years ago

@master-lincoln you can use self-hosting and give badge the base URI of your server to perform its queries.

However I wonder if that issue can be even solved here, since the wget is performed by imagmagick. So shields.io need to fix their IPv6 config. I have filed a ticket over there.

master-lincoln commented 2 years ago

Thanks for opening a ticket in the right place :heart:

you can use self-hosting and give badge the base URI of your server to perform its queries.

But how? All I could see was that this is a hardcoded value: https://github.com/HazAT/badge/blob/master/lib/badge/base.rb#L30-L36