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

Fix exception schema parsing if _errors array is top-level #1813

Merged
merged 2 commits into from
Sep 19, 2021

Conversation

Xirado
Copy link
Contributor

@Xirado Xirado commented Sep 7, 2021

Pull Request Etiquette

Changes

  • Internal code
  • Library interface (affecting end-user code)
  • Documentation
  • Other: _____

Closes Issue: #1799

Description

This pull request fixes exception schema parsing if the _errors array is top-level instead of it being on a property

@MinnDevelopment
Copy link
Member

For reference, I also opened a docs PR: discord/discord-api-docs#3785

Copy link
Member

@MinnDevelopment MinnDevelopment left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably need to add a check for location.isEmpty() in the SchemaError#toString to make the output not add an empty line. Could you provide an example error log, so we can judge what it looks like?

@Xirado
Copy link
Contributor Author

Xirado commented Sep 8, 2021

Probably need to add a check for location.isEmpty() in the SchemaError#toString to make the output not add an empty line. Could you provide an example error log, so we can judge what it looks like?

@MinnDevelopment This is what it looks like without the isEmpty() check:

net.dv8tion.jda.api.exceptions.ErrorResponseException: 50035: Invalid Form Body

        - APPLICATION_COMMAND_TOO_LARGE: Command exceeds maximum size (4000)
        at net.dv8tion.jda.api.exceptions.ErrorResponseException.create(ErrorResponseException.java:191)
        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 at.xirado.test.Main.main(Main.java:39)

And this is what it looks like with the check in place

net.dv8tion.jda.api.exceptions.ErrorResponseException: 50035: Invalid Form Body
        - APPLICATION_COMMAND_TOO_LARGE: Command exceeds maximum size (4000)
        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 at.xirado.test.Main.main(Main.java:39)

Copy link
Member

@DV8FromTheWorld DV8FromTheWorld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Required for v4 LTS defines that something is slated for inclusion in the final v4 LTS builds
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants