Self-improving AI Employees for everyone
Python ai-agentsai-employeeai-employeesassistantautonomous-agentsco-employeescompanygrok-botinstinctloop-agentsmuseown-your-datapersonalself-hosted
fix(discord): register the socialSend adapter that was only ever imported
trohitg8c490739ad56
diff --git a/docs-internal/discord_service.md b/docs-internal/discord_service.mdindex 4cf8dbe1..a036f393 100644--- a/docs-internal/discord_service.md+++ b/docs-internal/discord_service.md@@ -235,8 +235,10 @@ schemas, two filter builders, a trigger precheck, service refresh, two canarytrigger types, the social send adapter, and a shutdown hook.Outside the folder: `nodes/groups.py`, `config/credential_providers.json`,-`config/node_allowlist.json`, `constants.py` (both trigger frozensets), and the-three lists in `tests/test_plugin_self_containment.py`.+`config/node_allowlist.json`, `constants.py` (both trigger frozensets), the+three lists in `tests/test_plugin_self_containment.py`, and+`SOCIAL_PLATFORM_PLUGINS` in `tests/test_social_provider_registry.py`, which+is what asserts the adapter is actually registered rather than just imported.**`import discord` never appears at module scope** in any file the pluginwalker touches. [`nodes/__init__.py`](../server/nodes/__init__.py) swallowsdiff --git a/server/nodes/discord/__init__.py b/server/nodes/discord/__init__.pyindex 79b3ed29..bcc29da4 100644--- a/server/nodes/discord/__init__.py+++ b/server/nodes/discord/__init__.py@@ -68,6 +68,10 @@ register_service_refresh(refresh_discord_status)register_canary_trigger_type(DiscordReceiveNode.type, MESSAGE_RECEIVED_TYPE)register_canary_trigger_type(DiscordInteractionNode.type, INTERACTION_CREATED_TYPE)+# socialSend offers "discord" in its channel enum; this is what makes that+# entry dispatch somewhere instead of failing with "no registered handler".+register_social_send_handler("discord", social_send_adapter)+# Sessions left open count against the account's concurrent-session limit# until Discord times them out, which across dev restarts looks like a second# instance that will not go away.diff --git a/server/tests/test_social_provider_registry.py b/server/tests/test_social_provider_registry.pyindex ea511d23..9f0fae29 100644--- a/server/tests/test_social_provider_registry.py+++ b/server/tests/test_social_provider_registry.py@@ -174,22 +174,28 @@ class TestNoCrossPluginReachInSocialBase:)+# Every plugin that ships a social_send_adapter, with the channel it registers+# under. A plugin that imports its adapter but never calls+# register_social_send_handler passes every other test in this file and fails+# only at runtime, so each one is listed here explicitly.+SOCIAL_PLATFORM_PLUGINS = [+ ("nodes.whatsapp", "whatsapp"),+ ("nodes.whatsapp_business", "whatsapp_business"),+ ("nodes.discord", "discord"),+]++class TestWhatsappPluginSelfRegistersAsSocialProvider:"""Importing a platform plugin registers its social send handler.The two WhatsApp plugins are separate platforms: ``nodes/whatsapp/``drives a personal account through the Go bridge, ``nodes/whatsapp_business/``the official Cloud API. They share no credential and no API, so they- register under distinct keys and socialSend offers both.+ register under distinct keys and socialSend offers both. Discord is the+ third registered platform."""- @pytest.mark.parametrize(- "module, platform",- [- ("nodes.whatsapp", "whatsapp"),- ("nodes.whatsapp_business", "whatsapp_business"),- ],- )+ @pytest.mark.parametrize("module, platform", SOCIAL_PLATFORM_PLUGINS)def test_plugin_import_populates_registry(self, module, platform):from services.plugin import social_provider_registry as reg@@ -212,16 +218,15 @@ class TestWhatsappPluginSelfRegistersAsSocialProvider:break startup instead."""from services.plugin import social_provider_registry as reg- for module in ("nodes.whatsapp", "nodes.whatsapp_business"):+ for module, _platform in SOCIAL_PLATFORM_PLUGINS:try:__import__(module)except ImportError as exc: # pragma: no coverpytest.xfail(f"{module} not importable: {exc}")- personal = reg.get_social_send_handler("whatsapp")- business = reg.get_social_send_handler("whatsapp_business")- assert personal is not None and business is not None- assert personal is not business+ handlers = [reg.get_social_send_handler(p) for _m, p in SOCIAL_PLATFORM_PLUGINS]+ assert all(h is not None for h in handlers)+ assert len({id(h) for h in handlers}) == len(handlers)def test_every_registered_platform_is_selectable(self):"""A registered platform absent from socialSend's channel enum is@@ -230,7 +235,7 @@ class TestWhatsappPluginSelfRegistersAsSocialProvider:from nodes.social.social_send import SocialSendParamsfrom services.plugin import social_provider_registry as reg- for module in ("nodes.whatsapp", "nodes.whatsapp_business"):+ for module, _platform in SOCIAL_PLATFORM_PLUGINS:try:__import__(module)except ImportError as exc: # pragma: no cover