Skip to content

[Bug]: JsonSerializationException when deserializing messages with ComponentType 20 #3205

@SlavaSotnikov

Description

@SlavaSotnikov

Check The Docs

  • I double checked the docs and couldn't find any useful information.

Verify Issue Source

  • I verified the issue was caused by Discord.Net.

Check your intents

  • I double checked that I have the required intents.

Description

When fetching Discord messages that contain a message component with type: 20, the library throws a JsonSerializationException with the message "Unknown component type value '20' while deserializing message component". This causes the entire message deserialization to fail, preventing applications from processing messages that contain this unknown component type.

Version

3.18.0, 3.18.0-nightly.20251128.696

Working Version

No response

Logs

System.AggregateException: One or more errors occurred. (Unknown component type value '20' while deserializing message component)
 ---> Newtonsoft.Json.JsonSerializationException: Unknown component type value '20' while deserializing message component
   at Discord.Net.Converters.MessageComponentConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at Discord.Net.Converters.ArrayConverter`1.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at Discord.Net.Converters.OptionalConverter`1.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.Deserialize[T](JsonReader reader)
   at Discord.API.DiscordRestApiClient.DeserializeJson[T](Stream jsonStream)
   at Discord.API.DiscordRestApiClient.SendAsync[TResponse](String method, String endpoint, BucketId bucketId, ClientBucketType clientBucket, RequestOptions options)
   at Discord.Rest.ChannelHelper.<>c__DisplayClass10_0.<<GetMessagesAsync>b__0>d.MoveNext()

Sample

The current ComponentType enum in Discord.Net.Core defines values up to 19 (FileUpload):

  • ActionRow = 1
  • Button = 2
  • SelectMenu = 3
  • TextInput = 4
  • UserSelect = 5
  • RoleSelect = 6
  • MentionableSelect = 7
  • ChannelSelect = 8
  • Section = 9
  • TextDisplay = 10
  • Thumbnail = 11
  • MediaGallery = 12
  • File = 13
  • Separator = 14
  • Container = 17
  • Label = 18
  • FileUpload = 19

ComponentType 20 is not defined, but Discord is sending it in some messages.

Packages

3rd Party Packages

Discord.Net Dependencies:

  • Newtonsoft.Json Version 13.0.4
  • System.Linq.AsyncEnumerable Version 10.0.0

Application Packages (for context):

  • .NET 8.0 runtime

Environment

  • Discord.Net Versions: 3.18.0, 3.18.0-nightly.20251128.696
  • .NET Version: .NET 8.0
  • Operating System: Ubuntu 22.04

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions