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

UnpackResponseAsync fails to get content of a 400 error correctly #26

Open
b-rad15 opened this issue Feb 11, 2024 · 0 comments
Open

UnpackResponseAsync fails to get content of a 400 error correctly #26

b-rad15 opened this issue Feb 11, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@b-rad15
Copy link
Contributor

b-rad15 commented Feb 11, 2024

Copied from Remora/Remora.Discord#326

Description

When unpacking a 400 response from a webhook send I noticed that it was returning a simple HttpResultError (Code=400, Reason=Bad Request) despite the response containing content that explains the error in detail. Reading the response content using ReadAsStringAsync via the debugger correctly lets the library create the error object

Steps to Reproduce

Result<IMessage?> webhookResult = await _webhookApi.ExecuteWebhookAsync(<webhook id>, <webhook token>, content: "test", allowedMentions: new AllowedMentions(Parse: new[] { MentionType.Users }, Users: new Snowflake[] { new(0)) })); //This is code I had that triggered the bug

Expected Behavior

The response given in postman is {"allowed_mentions": ["parse:[\"users\"] and users: [ids...] are mutually exclusive."]}. This should resolve to a RestResultError when the content is read by UnpackResponseAsync.
In UnpackResonseAsync at like line ~654 of HttpRestClient, response.Content.Headers.ContentLength should be a positive integer but is instead null unless read manually in the debugger

Current Behavior

The error in the result is simply an HttpResultError

Library / Runtime Information

net8.0
Remora.Discord 2024.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant