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

HTTP 400 bad request on ChannelMessageSendEmbed with missing value #726

Closed
Heanthor opened this issue Jan 2, 2020 · 3 comments · Fixed by #1262
Closed

HTTP 400 bad request on ChannelMessageSendEmbed with missing value #726

Heanthor opened this issue Jan 2, 2020 · 3 comments · Fixed by #1262

Comments

@Heanthor
Copy link
Contributor

Heanthor commented Jan 2, 2020

Hi,

I'm seeing a discord API error while using ChannelMessageSendEmbed. The error is:

error="HTTP 400 Bad Request, {\"embed\": [\"fields\"]}"

It seems like this is caused by an empty value key in the MessageEmbedField struct. Value is json tagged as omitempty, would it make sense to remove this tag so the key is sent every time?

@CarsonHoffman
Copy link
Collaborator

This isn't caused by the omitempty tag; field values cannot be an empty string on the API level.

@Heanthor
Copy link
Contributor Author

Heanthor commented Jan 3, 2020

Good to know, should discordgo throw an error for blank values then? The API response is non-specific and doesn't really help solve the problem.

@CarsonHoffman
Copy link
Collaborator

The library in general doesn't really check for invalid inputs, as these can change over time on Discord's end and there generally isn't a ton of documentation on exactly what inputs are rejected and what aren't. The impetus of ensuring inputs are valid is generally left to the user in these scenarios, and setting a precedent otherwise would require a large shift in library code; I know it's not an ideal solution, but the general mission of the library is to be as low-level as possible.

A2-NieR added a commit to A2-NieR/discordgo that referenced this issue Oct 22, 2022
Remove omitempty from Name/value since the Discord API requires both to be submitted.

Fixes: bwmarrin#726
FedorLap2006 pushed a commit that referenced this issue Oct 23, 2022
Remove omitempty from Name/value since the Discord API requires both to be submitted.

Fixes: #726
LWCoder pushed a commit to AtTheTavern/discordgo that referenced this issue Apr 11, 2023
Remove omitempty from Name/value since the Discord API requires both to be submitted.

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

Successfully merging a pull request may close this issue.

2 participants