Jda: NPE when sending plain Webhook message with no embed

Created on 31 Jan 2018  路  3Comments  路  Source: DV8FromTheWorld/JDA

General Troubleshooting

Hey there! Before you report a bug or suggest a new feature,
please make sure to follow these steps first!

  • [x] I have checked for similar issues.
  • [x] I have updated to the latest JDA version.
  • [x] I have checked the branches or the maintainers' PRs for upcoming features/bug fixes.

This is not the place to learn Java. Please refer to StackOverflow
for your general programming questions.

Issue

Issue Type

  • [x] Bug Report
  • [ ] Feature Request

For questions join the official JDA discord server: https://discord.gg/0hMr4ce0tIl3SLv5

Description

Sending a Webhook message without an embed throws an NPE.

Stacktrace:

java.lang.NullPointerException: null
    at net.dv8tion.jda.webhook.WebhookMessage.getBody(WebhookMessage.java:136)
    at net.dv8tion.jda.webhook.WebhookClient.send(WebhookClient.java:130)
    at net.dv8tion.jda.webhook.WebhookClient.send(WebhookClient.java:241)
    at fredboat.event.EventLogger.drainMessageQueue(EventLogger.java:266)

Here are some relevant points:

A nullable embed gets put into a list: https://github.com/DV8FromTheWorld/JDA/blob/38e5aa9bfe193e0b94f92553a28f419f3b264277/src/main/java/net/dv8tion/jda/core/entities/impl/DataMessage.java#L77

Building a webhook message from a message fetches all embeds of the message:
https://github.com/DV8FromTheWorld/JDA/blob/38e5aa9bfe193e0b94f92553a28f419f3b264277/src/main/java/net/dv8tion/jda/webhook/WebhookMessage.java#L112

This line then causes the NPE:
https://github.com/DV8FromTheWorld/JDA/blob/38e5aa9bfe193e0b94f92553a28f419f3b264277/src/main/java/net/dv8tion/jda/webhook/WebhookMessage.java#L136

Not sure where you want to fix this in your message stack, I'd have made a PR otherwise.

bug completed

Most helpful comment

Let this is a benchmark for how all bug reports should be.
Very clean and helpful report @napstr.

All 3 comments

This has been fixed on the latest development build and will be in the next release. Thank you for reporting!

Let this is a benchmark for how all bug reports should be.
Very clean and helpful report @napstr.

While i do understand that some people do not have the technical know-how to look at lib sources and trace down the exact thing that happens, a stacktrace like here, with a bit of explanation what triggers the error (sending webhook message without embed) is all we need for bug reports

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stefaandevylder picture stefaandevylder  路  5Comments

YukioKeno picture YukioKeno  路  6Comments

Frederikam picture Frederikam  路  4Comments

MinnDevelopment picture MinnDevelopment  路  5Comments

Bungeefan picture Bungeefan  路  6Comments