The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(gateway): restore platform enum in destination restore
JerryLiu3696c032827a129
diff --git a/gateway/run_inbound_consumer.py b/gateway/run_inbound_consumer.pyindex 4caa695992c..f305153e529 100644--- a/gateway/run_inbound_consumer.py+++ b/gateway/run_inbound_consumer.py@@ -218,7 +218,15 @@ def _restore_destination_if_mutated(event: Any, source: Any, snapshot: Dict[str,try:for key, value in snapshot.items():if key == "platform":- continue # platform enum restore handled below+ # The snapshot stores the enum's .value; coerce back so the+ # attribute lands on the enum, not a bare string.+ from gateway.config import Platform++ try:+ setattr(source, key, Platform(value))+ except ValueError:+ setattr(source, key, value)+ continuesetattr(source, key, value)# Restore the event's source reference when it was swapped wholesale.if getattr(event, "source", None) is not source:diff --git a/tests/gateway/test_post_gateway_admission.py b/tests/gateway/test_post_gateway_admission.pyindex 027baedd4b9..af39d8a4896 100644--- a/tests/gateway/test_post_gateway_admission.py+++ b/tests/gateway/test_post_gateway_admission.py@@ -431,6 +431,7 @@ async def test_destination_mutation_is_restored(monkeypatch):event = kwargs.get("event")if name == POST_HOOK:event.source.chat_id = "EVIL-CHAT"+ event.source.platform = Platform.TELEGRAMevent.text = "mutated text is allowed"return [{"action": "pass"}]return []@@ -443,7 +444,9 @@ async def test_destination_mutation_is_restored(monkeypatch):)assert handled is False and reply is Noneassert out_source.chat_id == "[email protected]"+ assert out_source.platform is Platform.WHATSAPPassert out_event.source.chat_id == "[email protected]"+ assert out_event.source.platform is Platform.WHATSAPP@pytest.mark.asyncio