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

500 Internal Server Error when sending an invalid emoji ID

Open plun1331 opened this issue 1 year ago • 2 comments

Description

When trying to create a message with a select option that contains an emoji ID that is too large, (e.g. 99361420069595959602), the API will respond with a 500 status code.

Example Payload:

{
    "components": [
        {
            "type": 1,
            "components": [
                {
                    "type": 3,
                    "custom_id": "switch-sub",
                    "min_values": 1,
                    "max_values": 1,
                    "options": [
                        {
                            "label": "Entrance",
                            "value": "0",
                            "default": false,
                            "emoji": {
                                "name": "cata_entrance",
                                "id": 99361420069595959602
                            }
                        }
                    ]
                }
            ]
        }
    ]
}

Steps to Reproduce

  • Attempt to create a message with the above example payload
  • Get a 500 status code back
curl -XPOST -H "Content-type: application/json" -d '{
    "components": [
        {
            "type": 1,
            "components": [
                {
                    "type": 3,
                    "custom_id": "switch-sub",
                    "min_values": 1,
                    "max_values": 1,
                    "options": [
                        {
                            "label": "Entrance",
                            "value": "0",
                            "default": false,
                            "emoji": {
                                "name": "cata_entrance",
                                "id": 99361420069595959602
                            }
                        }
                    ]
                }
            ]
        }
    ]
}' 'https://discord.com/api/v10/channels/{channel.id}/messages'

Expected Behavior

The API responds with a proper error, such as a 400 Bad Request

Current Behavior

The API responds with a 500 Internal Server Error

Screenshots/Videos

No response

Client and System Information

  • Python v3.10.2-final
  • py-cord v2.0.0-candidate
    • py-cord pkg_resources: v2.0.0rc1
    • aiohttp v3.8.1
  • system info: Windows 10 10.0.22000

plun1331 avatar Jul 04 '22 22:07 plun1331

~~ids should be sent as strings~~

AlmostSuspense avatar Jul 05 '22 13:07 AlmostSuspense

snowflakes can be sent as integers (this has always worked). In fact, the docs says that Discord handle them internally as integers. They are however always returned as string by the API to prevent overflows in some languages.

The error reported in this issue can also be reproduced when sending the (invalid) ID as a string.

Zoddo avatar Jul 05 '22 17:07 Zoddo