discord / discord-api-docs

Official Discord API Documentation
https://discord.com/developers/docs/intro
Other
5.96k stars 1.26k forks source link

500 Internal Server Error when sending an invalid emoji ID #5159

Open plun1331 opened 2 years ago

plun1331 commented 2 years ago

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

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

AlmostSuspense commented 2 years ago

ids should be sent as strings

Zoddo commented 2 years ago

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.