fix(input): refine input handling and improve event robustness (#8472)

* Update model_input_constants.py

* Update component.py

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Eric Hare <ericrhare@gmail.com>
This commit is contained in:
Edwin Jose 2025-06-12 12:47:18 -05:00 committed by GitHub
commit 892ffe6bd9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1399,7 +1399,14 @@ class Component(CustomComponent):
case "error":
self._event_manager.on_error(data=data_dict)
case "remove_message":
self._event_manager.on_remove_message(data={"id": data_dict["id"]})
# Check if id exists in data_dict before accessing it
if "id" in data_dict:
self._event_manager.on_remove_message(data={"id": data_dict["id"]})
else:
# If no id, try to get it from the message object or id_ parameter
message_id = getattr(message, "id", None) or id_
if message_id:
self._event_manager.on_remove_message(data={"id": message_id})
case _:
self._event_manager.on_message(data=data_dict)