Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sending components with non-application-owned webhooks does not send an error response #5744

Closed
CheesyGamer77 opened this issue Dec 12, 2022 · 6 comments
Labels

Comments

@CheesyGamer77
Copy link

CheesyGamer77 commented Dec 12, 2022

Description

Sending message components with a non-application-owned Webhook results in a success response instead of an error response. This incorrectly communicates to the user that the request was valid, even though the request was in fact not valid. Resulting messages always contain empty components, with other fields in-tact. The documentation should reflect this behavior if intentional.

Sending Content and Components

Sending the following payload

{
    "content": "Test",
    "components": [
        {
            "type": 1,
            "components": [
                {
                    "type": 2,
                    "label": "Test",
                    "custom_id": "test",
                    "style": 1,
                }
            ]
        }
    ]
}

Results in the following message payload being created

{
	"id": "[redacted]",
	"type": 0,
	"content": "Test",
	"channel_id": "[redacted]",
	"author": {
		"bot": true,
		"id": "[redacted]",
		"username": "Test",
		"avatar": null,
		"discriminator": "0000"
	},
	"attachments": [],
	"embeds": [],
	"mentions": [],
	"mention_roles": [],
	"pinned": false,
	"mention_everyone": false,
	"tts": false,
	"timestamp": "2022-12-12T22:20:09.994000+00:00",
	"edited_timestamp": null,
	"flags": 0,
	"components": [],
	"webhook_id": "[redacted]"
}

Sending Only Components

Specifying only message components via the following

{
    "components": [
        {
            "type": 1,
            "components": [
                {
                    "type": 2,
                    "label": "Test",
                    "custom_id": "test",
                    "style": 1
                }
            ]
        }
    ]
}

Results in the following empty message being created

{
	"id": "[redacted]",
	"type": 0,
	"content": "",
	"channel_id": "[redacted]",
	"author": {
		"bot": true,
		"id": "[redacted]",
		"username": "Test",
		"avatar": null,
		"discriminator": "0000"
	},
	"attachments": [],
	"embeds": [],
	"mentions": [],
	"mention_roles": [],
	"pinned": false,
	"mention_everyone": false,
	"tts": false,
	"timestamp": "2022-12-12T22:24:42.271000+00:00",
	"edited_timestamp": null,
	"flags": 0,
	"components": [],
	"webhook_id": "[redacted]"
}

Steps to Reproduce

  1. Send the following cURL with content and components specified
curl --request POST \
  --url 'https://discord.com/api/v10/webhooks/<webhook_id>/<webhook_token>?wait=true' \
  --header 'content-type: application/json' \
  --data '{
    "components": [
        {
            "type": 1,
            "components": [
                {
                    "type": 2,
                    "label": "Test",
                    "custom_id": "test",
                    "style": 1
                }
            ]
        }
    ]
}'
  1. Receive an HTTP 200 response with content, but empty components, embeds, and attachments

  2. Send the following cURL with only components specified

curl --request POST \
  --url 'https://discord.com/api/v10/webhooks/<webhook_id>/<webhook_token>?wait=true' \
  --header 'content-type: application/json' \
  --data '{
    "components": [
        {
            "type": 1,
            "components": [
                {
                    "type": 2,
                    "label": "Test",
                    "custom_id": "test",
                    "style": 1
                }
            ]
        }
    ]
}'
  1. Receive an HTTP 200 response with content, components, embeds, and attachments all being empty

Expected Behavior

Receive an HTTP 400 Bad Request error response due to sending components from a non-app-owned webhook

Current Behavior

Receive an HTTP 200 OK success response instead, with components always being empty

Screenshots/Videos

No response

Client and System Information

HTTP Client: Insomnia 2022.6.0
OS: Windows 10 Pro 64bit, version 22H2

@yonilerner
Copy link
Member

We do not respond with 400 for extra fields. Extra fields are simply ignored. The documentation already indicates that this is not allowed.

@yonilerner yonilerner closed this as not planned Won't fix, can't repro, duplicate, stale Dec 22, 2022
@splatterxl
Copy link
Contributor

@yonilerner I believe the bug report is about the endpoint creating an empty message by ignoring the extra field, which is probably unintended.

@harshpandey002
Copy link

Hey, I'm building a dashboard for my bot, and I need to send messages as Bot that contains components and content. I'm "createMessage" rest api to send the message but the components are empty in the response just like @CheesyGamer77 mentioned.

Channel for the message is selected by user and could be anyone from the guild.

how implement this ? do I need to create webhook everytime? where can I learn more about application-owned webhooks?

@splatterxl @yonilerner

@yonilerner
Copy link
Member

@harshpandey002 Please open a new issue and include the exact request (with secrets removed) and response you're using

@BurkenDev
Copy link

@harshpandey002 Please open a new issue and include the exact request (with secrets removed) and response you're using

Please don't be that kind of commenter, just answer his question. Instead of being so rude.

@SinisterRectus
Copy link
Contributor

It was solved in #6563.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants