fix(tools): point email home-channel error at EMAIL_HOME_ADDRESS

The no-home-channel error for send_message derived the env var name
generically as <PLATFORM>_HOME_CHANNEL, producing EMAIL_HOME_CHANNEL for
the email platform. But gateway/config.py reads EMAIL_HOME_ADDRESS, so a
user following the error's guidance would set a variable that is never
consulted. Add a per-platform override map so the email hint names the
variable actually read; all other platforms keep the generic hint.
This commit is contained in:
teknium1
2026-05-30 02:39:08 -07:00
committed by Teknium
parent d3724c0be6
commit bfc4a26032
2 changed files with 57 additions and 1 deletions
+48
View File
@@ -1256,6 +1256,54 @@ class TestParseTargetRefEmail:
assert _parse_target_ref("slack", "user@example.com")[2] is False
class TestEmailHomeChannelErrorHint:
"""The no-home-channel error for email points at the real env var.
Email reads its home channel from EMAIL_HOME_ADDRESS (gateway/config.py),
not the generic EMAIL_HOME_CHANNEL. The error guidance must name the
variable that is actually consulted so users who follow it succeed.
"""
def test_email_error_names_email_home_address(self):
email_cfg = SimpleNamespace(enabled=True, token="", extra={})
config = SimpleNamespace(
platforms={Platform.EMAIL: email_cfg},
get_home_channel=lambda _platform: None,
)
with patch("gateway.config.load_gateway_config", return_value=config), \
patch("tools.interrupt.is_interrupted", return_value=False):
result = json.loads(
send_message_tool(
{
"action": "send",
"target": "email",
"message": "hi",
}
)
)
assert "EMAIL_HOME_ADDRESS" in result["error"]
assert "EMAIL_HOME_CHANNEL" not in result["error"]
def test_non_email_platform_keeps_generic_home_channel_hint(self):
telegram_cfg = SimpleNamespace(enabled=True, token="***", extra={})
config = SimpleNamespace(
platforms={Platform.TELEGRAM: telegram_cfg},
get_home_channel=lambda _platform: None,
)
with patch("gateway.config.load_gateway_config", return_value=config), \
patch("tools.interrupt.is_interrupted", return_value=False):
result = json.loads(
send_message_tool(
{
"action": "send",
"target": "telegram",
"message": "hi",
}
)
)
assert "TELEGRAM_HOME_CHANNEL" in result["error"]
class TestSendDiscordThreadId:
"""_send_discord uses thread_id when provided."""