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

Max application command size response can not be parsed #1799

Closed
GriffinCodes opened this issue Aug 31, 2021 · 0 comments
Closed

Max application command size response can not be parsed #1799

GriffinCodes opened this issue Aug 31, 2021 · 0 comments
Labels
bug level: novice is doable as a java/jda novice status: completed has been completed but is not yet released

Comments

@GriffinCodes
Copy link

GriffinCodes commented Aug 31, 2021

Bug Report

When you send a command that exceeds Discord's max command size, the error that returns cannot be parsed by JDA

(Note: it seems there is a bug with Discord that allows already existing commands to exceed the max size, so to reproduce this you will have to create a new command)

Code Example or Reproduction Steps

		final CommandData command = new CommandData("test-max-app-command-size", "Testing max app command size");
		for (int i = 0; i < 25; i++) {
			final SubcommandData subcommand = new SubcommandData("test-" + i, "test-" + i);
			for (int j = 0; j < 25; j++) {
				final String id = String.format("test-%d-%d", i, j);
				subcommand.addOption(OptionType.STRING, id, id);
			}
			command.addSubcommands(subcommand);
		}

		JDA.getGuildById("XXXXXXXXXXXXXXX").upsertCommand(command).queue(
			success -> System.out.println("Success"),
			failure -> failure.printStackTrace()
		);

Code for JDABuilder or DefaultShardManagerBuilder Used

		JDA = JDABuilder.createDefault(Config.DISCORD_TOKEN)
			.addEventListeners(getListeners().toArray())
			.build()
			.awaitReady();

Exception or Error

[main] INFO JDA - Login Successful!
[JDA MainWS-ReadThread] INFO WebSocketClient - Connected to WebSocket
[JDA MainWS-ReadThread] INFO JDA - Finished Loading!
[JDA RateLimit-Worker 1] ERROR ErrorResponseException - Failed to parse parts of error response. Body: N/A
net.dv8tion.jda.api.exceptions.ParsingException: Cannot parse value for _errors into type Map: [{code=APPLICATION_COMMAND_TOO_LARGE, message=Command exceeds maximum size (4000)}] instance of ArrayList
        at net.dv8tion.jda.api.utils.data.DataObject.get(DataObject.java:832)
        at net.dv8tion.jda.api.utils.data.DataObject.get(DataObject.java:813)
        at net.dv8tion.jda.api.utils.data.DataObject.optObject(DataObject.java:298)
        at net.dv8tion.jda.api.utils.data.DataObject.getObject(DataObject.java:277)
        at net.dv8tion.jda.api.exceptions.ErrorResponseException.parseSchema(ErrorResponseException.java:193)
        at net.dv8tion.jda.api.exceptions.ErrorResponseException.lambda$create$0(ErrorResponseException.java:171)
        at java.base/java.util.Optional.ifPresent(Optional.java:178)
        at net.dv8tion.jda.api.exceptions.ErrorResponseException.create(ErrorResponseException.java:171)
        at net.dv8tion.jda.api.requests.Request.onFailure(Request.java:117)
        at net.dv8tion.jda.internal.requests.RestActionImpl.handleResponse(RestActionImpl.java:270)
        at net.dv8tion.jda.api.requests.Request.handleResponse(Request.java:259)
        at net.dv8tion.jda.internal.requests.Requester.execute(Requester.java:237)
        at net.dv8tion.jda.internal.requests.Requester.execute(Requester.java:141)
        at net.dv8tion.jda.internal.requests.Requester.execute(Requester.java:124)
        at net.dv8tion.jda.internal.requests.ratelimit.BotRateLimiter$Bucket.run(BotRateLimiter.java:478)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
        at java.base/java.lang.Thread.run(Thread.java:831)
net.dv8tion.jda.api.exceptions.ErrorResponseException: 50035: Invalid Form Body
        at net.dv8tion.jda.api.exceptions.ErrorResponseException.create(ErrorResponseException.java:185)
        at net.dv8tion.jda.api.requests.Request.onFailure(Request.java:117)
        at net.dv8tion.jda.internal.requests.RestActionImpl.handleResponse(RestActionImpl.java:270)
        at net.dv8tion.jda.api.requests.Request.handleResponse(Request.java:259)
        at net.dv8tion.jda.internal.requests.Requester.execute(Requester.java:237)
        at net.dv8tion.jda.internal.requests.Requester.execute(Requester.java:141)
        at net.dv8tion.jda.internal.requests.Requester.execute(Requester.java:124)
        at net.dv8tion.jda.internal.requests.ratelimit.BotRateLimiter$Bucket.run(BotRateLimiter.java:478)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
        at java.base/java.lang.Thread.run(Thread.java:831)
Caused by: net.dv8tion.jda.api.exceptions.ContextException
        at net.dv8tion.jda.api.exceptions.ContextException.here(ContextException.java:54)
        at net.dv8tion.jda.api.requests.Request.<init>(Request.java:71)
        at net.dv8tion.jda.internal.requests.RestActionImpl.queue(RestActionImpl.java:197)
        at gg.projecteden.jayce.Jayce.registerAppCommand(Jayce.java:232)
        at gg.projecteden.jayce.Jayce.jda(Jayce.java:79)
        at gg.projecteden.jayce.Jayce.<init>(Jayce.java:61)
        at gg.projecteden.jayce.Jayce.main(Jayce.java:53)
@MinnDevelopment MinnDevelopment added bug level: novice is doable as a java/jda novice up for grabs labels Aug 31, 2021
@DV8FromTheWorld DV8FromTheWorld added status: in progress already in the process of being implemented Required for v4 LTS status: completed has been completed but is not yet released and removed status: in progress already in the process of being implemented labels Sep 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug level: novice is doable as a java/jda novice status: completed has been completed but is not yet released
Projects
None yet
Development

No branches or pull requests

3 participants