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

[Bug]: Getting an auto mod message results in ExceptionError #297

Open
pititu opened this issue Apr 11, 2023 · 4 comments
Open

[Bug]: Getting an auto mod message results in ExceptionError #297

pititu opened this issue Apr 11, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@pititu
Copy link

pititu commented Apr 11, 2023

Description

Calling IDiscordRestChannelAPI#GetChannelMessageAsync with a message id of an auto mod action such as: image
returns a result whose Error is set to an ExceptionError.

The error:

ExceptionError 
{
	Message = Failed to deserialize an enumeration value., 
	Exception = System.Text.Json.JsonException: Failed to deserialize an enumeration value.
   at Remora.Rest.Json.StringEnumConverter`1.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.Deserialize(Utf8JsonReader& reader, ReadStack& state)
   at System.Text.Json.JsonSerializer.Read[TValue](Utf8JsonReader& reader, JsonTypeInfo`1 jsonTypeInfo)
   at System.Text.Json.JsonSerializer.Deserialize[TValue](Utf8JsonReader& reader, JsonSerializerOptions options)
   at Remora.Rest.Json.Internal.OptionalConverter`1.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.Deserialize(Utf8JsonReader& reader, ReadStack& state)
   at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.DeserializeAsObject(Utf8JsonReader& reader, ReadStack& state)
   at System.Text.Json.JsonSerializer.ReadAsObject(Utf8JsonReader& reader, JsonTypeInfo jsonTypeInfo)
   at System.Text.Json.JsonSerializer.Deserialize(Utf8JsonReader& reader, Type returnType, JsonSerializerOptions options)
   at Remora.Rest.Json.Internal.BoundDataObjectConverter`1.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.JsonCollectionConverter`2.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, TCollection& value)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.Deserialize(Utf8JsonReader& reader, ReadStack& state)
   at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.DeserializeAsObject(Utf8JsonReader& reader, ReadStack& state)
   at System.Text.Json.JsonSerializer.ReadAsObject(Utf8JsonReader& reader, JsonTypeInfo jsonTypeInfo)
   at System.Text.Json.JsonSerializer.Deserialize(Utf8JsonReader& reader, Type returnType, JsonSerializerOptions options)
   at Remora.Rest.Json.Internal.BoundDataObjectConverter`1.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.ContinueDeserialize(ReadBufferState& bufferState, JsonReaderState& jsonReaderState, ReadStack& readStack)
   at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.DeserializeAsync(Stream utf8Json, CancellationToken cancellationToken)
   at Remora.Rest.RestHttpClient`1.UnpackResponseAsync[TEntity](HttpResponseMessage response, String jsonPath, Boolean allowNullReturn, CancellationToken ct)
   at Remora.Rest.RestHttpClient`1.UnpackResponseAsync[TEntity](HttpResponseMessage response, String jsonPath, Boolean allowNullReturn, CancellationToken ct)
   at Remora.Rest.RestHttpClient`1.GetAsync[TEntity](String endpoint, String jsonPath, Action`1 configureRequestBuilder, Boolean allowNullReturn, CancellationToken ct)
}

Steps to Reproduce

  1. Call IDiscordRestChannelAPI#GetChannelMessageAsync with message id of a Discord's auto mod action
  2. Inspect the returned Result's Error

Expected Behavior

The method to return a successful Result<IMessage> with a valid Entity.

Current Behavior

A Result<IMessage> with the Error property set to ExceptionError is returned.

Library / Runtime Information

Remora.Discord.API: 73.0.0-github4632897105
Remora.Discord.API.Abstractions: 77.0.0-github4632897105

@pititu pititu added the bug Something isn't working label Apr 11, 2023
@VelvetToroyashi
Copy link
Contributor

VelvetToroyashi commented Apr 11, 2023

This is due to Automod using an undocumented embed type auto_moderation_message.

image

@Nihlus
Copy link
Member

Nihlus commented May 1, 2023

Could one of you open an issue on the docs repo for that type?

@VelvetToroyashi
Copy link
Contributor

They have no intentions on documenting this, as AutoMod is "in beta and still being finalized" if memory serves.

@VelvetToroyashi
Copy link
Contributor

That and embed types being deprecated, as far as the documentation is concerned.

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

3 participants