1

My telegram bot is experiencing issues with sending pics from by DigitalOcean Spaces CDN. The most frustrating part here is that most of the pics are sent without any error, however some particular images are resulting in BadRequest 400 error from Telegram Bot API.

The images are completely identical in terms of their format and meta data, but for some reason Telegram refuses to load some of them (Even when I send a URL to a "broken" image, Telegram does not display the preview).

The most sick part here is that some "broken" pictures are getting accepted when I add .cdn subdomain to the URL and vice versa -- some "broken" pics with .cdn subdomain are getting accepted if I remove it.

  • OK image (no error, when sending from my personal account preview is shown)

  • broken image (error, when sending from my personal account no preview is shown).

  • magically cured broken image (no error, preview is shown, same as previous but without .cdn in the URL)

I would be grateful for any hint to resolve this problem

monomonedula
  • 606
  • 4
  • 17

1 Answers1

0

So it turns out, Telegram caches the responses (both successful and unsuccessful) from photo URLs. Therefore, if for some reason one of the URLs returned non-200 response, this response gets cached and all subsequent retries to send this image by the same URL will fail.

This answer contains info on how to update the cache.

monomonedula
  • 606
  • 4
  • 17