The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(webhook): validate the coalesce block on hot-reloaded dynamic routes
teknium16467172db98a
diff --git a/gateway/platforms/webhook.py b/gateway/platforms/webhook.pyindex 3f8cc0df35e..e8b13aa9973 100644--- a/gateway/platforms/webhook.py+++ b/gateway/platforms/webhook.py@@ -361,6 +361,12 @@ class WebhookAdapter(BasePlatformAdapter):logger.warning("[webhook] Dynamic route '%s' skipped: INSECURE_NO_AUTH is only allowed on loopback ""hosts. Current host: '%s'.", name, self._host)return False+ try:+ # Hot-reloaded from the request handler: a malformed block must skip the route, not 500 the request.+ validate_coalesce_config(name, route)+ except ValueError as e:+ logger.warning("[webhook] Dynamic route '%s' skipped: %s", name, e)+ return Falsereturn Truedef _reload_dynamic_routes(self) -> None:diff --git a/gateway/platforms/webhook_coalesce.py b/gateway/platforms/webhook_coalesce.pyindex a8aebbd587e..4afd4898f70 100644--- a/gateway/platforms/webhook_coalesce.py+++ b/gateway/platforms/webhook_coalesce.py@@ -4,8 +4,8 @@ Rapid distinct events on one logical entity (five pushes to a PR, a burst of ticcarry a fresh delivery ID, so idempotency cannot suppress them and every event wakes an agentrun. Coalescing groups events by a payload-derived key and debounces them: only the LATEST eventof a group is dispatched once the quiet window passes, bounded by ``max_wait_seconds`` past the-group's first event so a steady stream cannot starve dispatch. Port of RooCodeInc/Roomote#1478-(one durable review task per PR, stale heads superseded). #92066+group's first event so a steady stream cannot starve dispatch (one durable run per entity, stale+heads superseded). #92066"""from __future__ import annotationsdiff --git a/tests/gateway/test_webhook_coalescing.py b/tests/gateway/test_webhook_coalescing.pyindex 3a0385a01ef..f6479f79b1c 100644--- a/tests/gateway/test_webhook_coalescing.py+++ b/tests/gateway/test_webhook_coalescing.py@@ -51,9 +51,16 @@ def _payload(pr_number=None, action: str = "synchronize") -> bytes:({**_coalesce_route(), "deliver_only": True, "deliver": "telegram"}, "deliver_only"),({**_coalesce_route(), "cron_job": "sweeper"}, "cron_job"),])-async def test_invalid_coalesce_config_rejected_at_connect(route, match):+async def test_invalid_coalesce_config_rejected_at_connect(route, match, tmp_path, monkeypatch):with pytest.raises(ValueError, match=match):await _make_adapter(routes={"pr": route}).connect()+ # The same block on a hot-reloaded dynamic route is skipped (warned), never admitted — it would+ # otherwise raise inside the request handler.+ monkeypatch.setenv("HERMES_HOME", str(tmp_path))+ (tmp_path / "webhook_subscriptions.json").write_text(json.dumps({"dyn": route}), encoding="utf-8")+ adapter = _make_adapter()+ adapter._reload_dynamic_routes()+ assert "dyn" not in adapter._routes@pytest.mark.asyncio