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

Error in Sending Webhooks #11

Closed
G-Kumaran opened this issue Jul 25, 2020 · 14 comments
Closed

Error in Sending Webhooks #11

G-Kumaran opened this issue Jul 25, 2020 · 14 comments

Comments

@G-Kumaran
Copy link

G-Kumaran commented Jul 25, 2020

Version :

<dependency>
    <groupId>club.minnced</groupId>
    <artifactId>discord-webhooks</artifactId>
    <version>0.3.2</version>
</dependency>

Environment:
Java 8 with SpringBoot

Code:

WebhookClient.withUrl("https://discordapp.com/api/webhooks/736596600071127061/[REDACTED]")
     .send("Test");

Error:

ERROR 20760 --- [596600071127061] c.minnced.discord.webhook.WebhookClient  : Sending a webhook message failed with non-OK http response

club.minnced.discord.webhook.exception.HttpException: Request returned failure 400: {"code": 50035, "errors": {"allowed_mentions": {"_errors": [{"code": "MODEL_TYPE_CONVERT", "message": "Only dictionaries may be used in a ModelType"}]}}, "message": "Invalid Form Body"}
	at club.minnced.discord.webhook.WebhookClient.failure(WebhookClient.java:375) [discord-webhooks-0.3.2.jar:na]
	at club.minnced.discord.webhook.WebhookClient.executePair(WebhookClient.java:438) [discord-webhooks-0.3.2.jar:na]
	at club.minnced.discord.webhook.WebhookClient.drainQueue(WebhookClient.java:411) [discord-webhooks-0.3.2.jar:na]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[na:1.8.0_252]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[na:1.8.0_252]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) ~[na:1.8.0_252]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) ~[na:1.8.0_252]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[na:1.8.0_252]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[na:1.8.0_252]
	at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_252]
@MinnDevelopment
Copy link
Owner

I'm unable to reproduce this with your provided code.

@G-Kumaran
Copy link
Author

Yeah i received your ping.
But i can consistently reproduce this issue in my code.
Any more debugging info that i can provide to assist you?

@G-Kumaran
Copy link
Author

To test Ive manually created a webhook without this api and yet i still get this issue.
So I'm guessing issue isn't in the api...

Damn

@MinnDevelopment
Copy link
Owner

Potentially this is an issue with your dependencies which somehow conflict with the JSON library?

@G-Kumaran
Copy link
Author

You could be right, created a new project with only just the spring-boot-starter and the discord-webhooks dependancies without the any other dependancies. Webhooks now pass.
What json library is discord-webhooks api using? Im on Jackson.

@MinnDevelopment
Copy link
Owner

This library uses org.json:json:20180813

@kantenkugel
Copy link
Collaborator

Jackson shouldn't conflict with org.json though. More likely some of your other dependencies relies on a different version of org.json

@G-Kumaran
Copy link
Author

After hours of combination and errors, not able to identify the actual issue.

But found the cause of issue.

<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-test</artifactId>
	<scope>test</scope>
</dependency>

Addin this to the pom causes the issue, deleting this from the pom and webhook passes.

Can u reproduce the issue based on this?

@MinnDevelopment
Copy link
Owner

MinnDevelopment commented Jul 25, 2020

I don't use maven and have no maven setup but I assume the reason is that maven resolves dependencies on first sight rather than using the latest. The issue might be solved by putting this library as your first dependency.

@G-Kumaran
Copy link
Author

Update :
Analysis of packages inside the sping-boot-starter-boot:
This package is causing the issue.

<groupId>org.skyscreamer</groupId>
<artifactId>jsonassert</artifactId>

Source : https://github.com/skyscreamer/JSONassert
Im guessing somthing in this breaks the discord api.

Quick note, this is included in the default https://start.spring.io config.

@MinnDevelopment
Copy link
Owner

It's likely that some dependency causes a different version of the org.json.JSONObject class to load which can't handle the JSONString interface correctly.

@kantenkugel
Copy link
Collaborator

kantenkugel commented Jul 25, 2020

Well i think this issue explains it pretty well: spring-projects/spring-boot#8706

TL;DR: org.skyscreamer:jsonassert depends on com.vaadin.external.google:android-json, which in turn is a "re-implementation" of org.json (using same packages + classes), effectively breaking anything that wants to use actual org.json

@MinnDevelopment
Copy link
Owner

Then the solution is to exclude this android re-implementation. Closing as resolved.

@G-Kumaran
Copy link
Author

Thanks for the explanation @kantenkugel

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

No branches or pull requests

3 participants