Skip to content

The agent that grows with you

fix(cron): accurate error for relay-fronted delivery with no live gateway (NS-773)

Victor Kyriazakos2d1d65de46ac
diff --git a/cron/scheduler.py b/cron/scheduler.py
index a96b4175aef..07259230f02 100644
--- a/cron/scheduler.py
+++ b/cron/scheduler.py
@@ -3270,8 +3270,26 @@ def _deliver_result(job: dict, content: str, adapters=None, loop=None) -> Option
pconfig = transport.config
runtime_adapter = transport.adapter
else:
- # No live transport: preserve the existing standalone delivery path,
- # which uses the logical platform's configured credential.
+ # No live transport. A relay-fronted platform's ONLY sender is the
+ # gateway's live relay adapter — there is no standalone fallback
+ # (the connector owns the credential). A manual in-process run
+ # (`hermes cron run`) has no live relay adapter, so surface the
+ # accurate remediation instead of the native configured/enabled
+ # gate, which misdiagnoses relay-fronted deployments.
+ from gateway.relay import relay_fronted_platforms
+
+ if platform_name in relay_fronted_platforms():
+ msg = (
+ f"platform '{platform_name}' is relay-fronted and has no "
+ "live gateway transport; start the gateway or use "
+ "`hermes cron trigger` (the gateway ticker owns relay-"
+ "fronted delivery)"
+ )
+ logger.warning("Job '%s': %s", job["id"], msg)
+ delivery_errors.append(msg)
+ continue
+ # Preserve the existing standalone delivery path, which uses the
+ # logical platform's configured credential.
pconfig = config.platforms.get(platform)
runtime_adapter = None
diff --git a/tests/cron/test_relay_fronted_delivery.py b/tests/cron/test_relay_fronted_delivery.py
index eb5f0834989..76a7520f9c4 100644
--- a/tests/cron/test_relay_fronted_delivery.py
+++ b/tests/cron/test_relay_fronted_delivery.py
@@ -173,4 +173,19 @@ class TestRelayDeliveryGate:
config.get_home_channel = lambda p: None
result = self._run({}, config)
assert result is not None
- assert "not configured/enabled" in result
+
+ def test_relay_fronted_without_live_gateway_errors_accurately(self, monkeypatch):
+ """A relay-fronted platform with NO live relay transport (manual
+ in-process `hermes cron run`) fails with the accurate 'gateway required'
+ message — never the native 'not configured/enabled' gate, which
+ misdiagnoses relay-fronted deployments whose credential lives in the
+ connector, not natively."""
+ _clear_home_env(monkeypatch)
+ monkeypatch.setenv("GATEWAY_RELAY_PLATFORMS", "discord")
+ config = MagicMock()
+ config.platforms = {}
+ config.get_home_channel = lambda p: None
+ result = self._run({}, config) # no live adapters
+ assert result is not None
+ assert "relay-fronted" in (result or "")
+ assert "not configured" not in (result or "")