Skip to content

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

@ulnanlu

Description

@ulnanlu

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

Username string `json:"username"`
AvatarURL string `json:"avatar_url,omitempty"`

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions