Discord webhook sends a blank username property when username is not set causing a 400 error #14926

Closed
opened 2025-11-02 11:25:58 -06:00 by GiteaMirror · 0 comments
Owner

Originally created by @ulnanlu on GitHub (Sep 5, 2025).

Description

I believe the Username here should be set to omitempty like AvatarURL since username is not a required field for webhook requests. Sending it blank causes a 400 error.

Reference: https://discord.com/developers/docs/resources/webhook#execute-webhook-jsonform-params

07347634aa/services/webhook/discord.go (L60-L61)

Payload sent:

{
  "wait": false,
  "content": "",
  "username": "",
  "tts": false,
  "embeds": [
    ...
  ]
}

Error response from discord:

{"username": ["Must be between 1 and 80 in length.", "Username cannot be \"\""]}

Gitea Version

1.24.3

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

binaries provided by gitea

Database

None

Originally created by @ulnanlu on GitHub (Sep 5, 2025). ### Description I believe the `Username` here should be set to `omitempty` like `AvatarURL` since `username` is not a required field for webhook requests. Sending it blank causes a 400 error. Reference: https://discord.com/developers/docs/resources/webhook#execute-webhook-jsonform-params https://github.com/go-gitea/gitea/blob/07347634aa70defb7820332f4c860bb24f4ada2f/services/webhook/discord.go#L60-L61 Payload sent: ```json { "wait": false, "content": "", "username": "", "tts": false, "embeds": [ ... ] } ``` Error response from discord: ```json {"username": ["Must be between 1 and 80 in length.", "Username cannot be \"\""]} ``` ### Gitea Version 1.24.3 ### Can you reproduce the bug on the Gitea demo site? Yes ### Log Gist _No response_ ### Screenshots _No response_ ### Git Version _No response_ ### Operating System _No response_ ### How are you running Gitea? binaries provided by gitea ### Database None
GiteaMirror added the type/bug label 2025-11-02 11:25:58 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#14926