The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(slack): coerce string unfurl knobs on the native plane
Ben Barclay5521265defcc
diff --git a/plugins/platforms/slack/adapter.py b/plugins/platforms/slack/adapter.pyindex c27a65b2d1a..b83b70d61db 100644--- a/plugins/platforms/slack/adapter.py+++ b/plugins/platforms/slack/adapter.py@@ -85,13 +85,32 @@ def _slack_unfurl_kwargs(extra: Optional[Dict[str, Any]]) -> Dict[str, bool]:Omitting a key preserves Slack's existing default. Passing ``False``suppresses only the automatic preview while leaving the link text and URLin the message untouched.++ String booleans are coerced the same way as the relay plane's+ ``_slack_unfurl_hints``: ``hermes config set`` and Railway persist YAML+ ``"true"``/``"false"`` as strings, and a silently dropped string would+ make the knob a no-op on the native plane only. Unrecognized values are+ dropped (NOT coerced to False) so junk config keeps Slack's default+ instead of accidentally suppressing previews."""settings = extra or {}- return {- key: settings[key]- for key in ("unfurl_links", "unfurl_media")- if isinstance(settings.get(key), bool)- }+ kwargs: Dict[str, bool] = {}+ for key in ("unfurl_links", "unfurl_media"):+ val = settings.get(key)+ if isinstance(val, bool):+ kwargs[key] = val+ elif isinstance(val, str) and val.strip().lower() in {+ "1",+ "0",+ "true",+ "false",+ "yes",+ "no",+ "on",+ "off",+ }:+ kwargs[key] = val.strip().lower() in {"1", "true", "yes", "on"}+ return kwargsasync def _read_error_text_limited(diff --git a/tests/gateway/test_slack.py b/tests/gateway/test_slack.pyindex 29709db40f3..055b6ed35a1 100644--- a/tests/gateway/test_slack.py+++ b/tests/gateway/test_slack.py@@ -3520,21 +3520,26 @@ class TestMessageSplitting:assert "unfurl_media" not in kwargs@pytest.mark.asyncio- async def test_send_passes_unfurl_options_to_every_chunk(self, adapter):- adapter.config.extra["unfurl_links"] = False- adapter.config.extra["unfurl_media"] = False+ async def test_send_coerces_string_unfurl_options(self, adapter):+ """`hermes config set` / Railway persist YAML booleans as strings.++ Relay-plane parity: string "false"/"true" must coerce instead of+ being silently dropped (which would leave previews on with no error).+ """+ adapter.config.extra["unfurl_links"] = "false"+ adapter.config.extra["unfurl_media"] = "true"adapter._app.client.chat_postMessage = AsyncMock(return_value={"ts": "ts1"})- await adapter.send("C123", "https://example.com/" + "x" * 45000)+ await adapter.send("C123", "https://example.com")- assert adapter._app.client.chat_postMessage.call_count >= 2- for call in adapter._app.client.chat_postMessage.call_args_list:- assert call.kwargs["unfurl_links"] is False- assert call.kwargs["unfurl_media"] is False+ kwargs = adapter._app.client.chat_postMessage.call_args.kwargs+ assert kwargs["unfurl_links"] is False+ assert kwargs["unfurl_media"] is True@pytest.mark.asyncio- async def test_send_ignores_non_boolean_unfurl_options(self, adapter):- adapter.config.extra["unfurl_links"] = "false"+ async def test_send_drops_junk_unfurl_values(self, adapter):+ """Unrecognized values keep Slack's default rather than suppressing."""+ adapter.config.extra["unfurl_links"] = "maybe"adapter.config.extra["unfurl_media"] = 0adapter._app.client.chat_postMessage = AsyncMock(return_value={"ts": "ts1"})@@ -3544,6 +3549,19 @@ class TestMessageSplitting:assert "unfurl_links" not in kwargsassert "unfurl_media" not in kwargs+ @pytest.mark.asyncio+ async def test_send_passes_unfurl_options_to_every_chunk(self, adapter):+ adapter.config.extra["unfurl_links"] = False+ adapter.config.extra["unfurl_media"] = False+ adapter._app.client.chat_postMessage = AsyncMock(return_value={"ts": "ts1"})++ await adapter.send("C123", "https://example.com/" + "x" * 45000)++ assert adapter._app.client.chat_postMessage.call_count >= 2+ for call in adapter._app.client.chat_postMessage.call_args_list:+ assert call.kwargs["unfurl_links"] is False+ assert call.kwargs["unfurl_media"] is False+@pytest.mark.asyncioasync def test_send_does_not_double_escape_entities(self, adapter):"""Pre-escaped & in sent messages must not become &."""