Skip to content

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

Description

@b-rad15

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions