discord-api-docs icon indicating copy to clipboard operation
discord-api-docs copied to clipboard

HTTP 415 for image embed

Open kik-tibia opened this issue 4 months ago • 1 comments

Description

I have two identical image URLs, here: https://tibia.fandom.com/wiki/Special:Redirect/file/Nightfiend.gif https://tibia.fandom.com/wiki/Special:Redirect/file/Ravenous_Hunger.gif Discord is only embedding the first URL.

Steps to Reproduce

Send the following discord message:

https://tibia.fandom.com/wiki/Special:Redirect/file/Nightfiend.gif https://tibia.fandom.com/wiki/Special:Redirect/file/Ravenous_Hunger.gif

Expected Behavior

Two identical GIFs should be shown.

Current Behavior

Only the first image, Nightfiend.gif, is shown. Ravenous_Hunger.gif is not converted into an image. This affects bots and users. Additionally, running the 2nd URL through discord's Embed Debugger returns this warning:

  • Unable to extract thumbnail: HTTP status client error (415 Unsupported Media Type) for url (http://media-proxy-prd-main-t98t:4000/_metadata?placeholder_version=1)

It's not clear to me if there is a problem with the image URL or with Discord. When I download both images, they are identical (same md5sum), and the URLs both have the same HTTP headers and similar redirect steps.

Screenshots/Videos

image The first message demonstrates the problem, in that only one image is shown. The second message (with Troll.gif and Young_Troll.gif) demonstrates the expected behaviour for two identical images: both are shown.

Client and System Information

Windows 11 desktop client, Arch Linux desktop client.

kik-tibia avatar Feb 27 '24 17:02 kik-tibia

I did some more digging. Taking a look at the network requests sent by the Embed Debugger, it is calling the unfurler api to generate the thumbnail. For the working image, Nightfiend.gif, the headers in the JSON response are:

    "headers": {
      "content-disposition": "inline; filename=\"Nightfiend.gif\"; filename*=UTF-8''Nightfiend.gif",
      "content-type": "image/gif"
    }

However, for the broken image, Ravenous_Hunger.gif, the content-type is webp:

    "headers": {
      "content-disposition": "inline; filename=\"Ravenous_Hunger.webp\"; filename*=UTF-8''Ravenous_Hunger.webp",
      "content-type": "image/webp"
    }

So for some reason, the unfurler thinks the broken image is a webp.

Next, I followed the image redirect to its destination and took a look at the content type.

curl -i "https://static.wikia.nocookie.net/tibia/images/4/4f/Ravenous_Hunger.gif/revision/latest?cb=20180125184028&path-prefix=en" content-type: image/gif

If I include the Accept: image/webp header, then the server does return a webp image instead. curl -i -H 'Accept: image/webp' "https://static.wikia.nocookie.net/tibia/images/4/4f/Ravenous_Hunger.gif/revision/latest?cb=20180125184028&path-prefix=en" content-type: image/webp

So, one possibility is that somewhere in the unfurler API is including the Accept: image/webp header despite Discord not supporting webp?

kik-tibia avatar Feb 27 '24 18:02 kik-tibia