From 1d3642d1fed01b18acc96a84c70d6198652f42aa Mon Sep 17 00:00:00 2001 From: Soheab_ <33902984+Soheab@users.noreply.github.com> Date: Sun, 21 Sep 2025 15:58:00 +0200 Subject: [PATCH] Fix KeyError on custom_id for modal components that don't support it --- discord/ui/modal.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/discord/ui/modal.py b/discord/ui/modal.py index 86c09da30..b1f86165a 100644 --- a/discord/ui/modal.py +++ b/discord/ui/modal.py @@ -175,9 +175,13 @@ class Modal(BaseView): elif component['type'] == 18: self._refresh(interaction, [component['component']]) else: - item = find(lambda i: getattr(i, 'custom_id', None) == component['custom_id'], self.walk_children()) # type: ignore + custom_id = component.get('custom_id') + if custom_id is None: + continue + + item = find(lambda i: getattr(i, 'custom_id', None) == custom_id, self.walk_children()) if item is None: - _log.debug('Modal interaction referencing unknown item custom_id %s. Discarding', component['custom_id']) + _log.debug('Modal interaction referencing unknown item custom_id %s. Discarding', custom_id) continue item._refresh_state(interaction, component) # type: ignore