Skip to content

Fix: Handle unknown components gracefully in ContainerComponents.UnmarshalJSON#497

Open
Wulgaren wants to merge 3 commits into
diamondburned:v3from
Wulgaren:v3
Open

Fix: Handle unknown components gracefully in ContainerComponents.UnmarshalJSON#497
Wulgaren wants to merge 3 commits into
diamondburned:v3from
Wulgaren:v3

Conversation

@Wulgaren

Copy link
Copy Markdown
  • Skip unknown components instead of failing when decoding message components
  • This allows messages with new Discord component types to still be loaded
  • Also added support for newer select component types (UserSelect, RoleSelect, MentionableSelect, ChannelSelect) in ParseComponent

…rshalJSON

- Skip unknown components instead of failing when decoding message components
- This allows messages with new Discord component types to still be loaded
- Also added support for newer select component types (UserSelect, RoleSelect, MentionableSelect, ChannelSelect) in ParseComponent
diamondburned
diamondburned previously approved these changes Apr 6, 2026
ayn2op
ayn2op previously approved these changes Apr 7, 2026
@ayn2op ayn2op dismissed stale reviews from diamondburned and themself via 80c37b3 April 9, 2026 00:46
@ayn2op ayn2op requested review from ayn2op and diamondburned April 9, 2026 00:46
diamondburned
diamondburned previously approved these changes Apr 9, 2026
ayn2op
ayn2op previously approved these changes Apr 9, 2026
Comment thread discord/component.go Outdated
Comment thread discord/component.go
Comment on lines +274 to +278
// If it's an unknown component, skip it instead of failing
// This allows messages with new component types to still be loaded
if _, isUnknown := p.(*UnknownComponent); isUnknown {
continue
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

isnt that branch is effectively unreachable? since *UnknownComponent implements TopLevelComponent, it is unreachable (!ok != false):
https://github.com/diamondburned/arikawa/pull/497/changes#diff-962d7ae8c081b5ff9c6617afaaf818bdba4b6245bddb2484609030c2e00d4e42R274-R278

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants