fix(channles):update the logger for the channel config (#2524)

* fix(channles):update the logger for the channel config

* fix(channels): normalize credential values and add tests for disabled-but-configured warning

Agent-Logs-Url: https://github.com/bytedance/deer-flow/sessions/dfc0a566-aa59-49f9-a74d-610292fb0a63

Co-authored-by: WillemJiang <219644+WillemJiang@users.noreply.github.com>

* fix the backend lint error

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
This commit is contained in:
Willem Jiang
2026-04-26 10:09:55 +08:00
committed by GitHub
parent 8a044142cb
commit 9dc25987e0
2 changed files with 79 additions and 1 deletions
+59
View File
@@ -2011,6 +2011,65 @@ class TestChannelService:
assert service.manager._langgraph_url == "http://custom-langgraph:2024"
assert service.manager._gateway_url == "http://custom-gateway:8001"
def test_disabled_channel_with_string_creds_emits_warning(self, caplog):
"""Warning is emitted when a channel has string credentials but enabled=false."""
import logging
from app.channels.service import ChannelService
async def go():
service = ChannelService(
channels_config={
"wecom": {"enabled": False, "bot_id": "corp123", "bot_secret": "secret"},
}
)
with caplog.at_level(logging.WARNING, logger="app.channels.service"):
await service.start()
await service.stop()
_run(go())
assert any("wecom" in r.message and r.levelno == logging.WARNING for r in caplog.records)
def test_disabled_channel_with_int_creds_emits_warning(self, caplog):
"""Warning is emitted even when YAML-parsed integer credentials are present."""
import logging
from app.channels.service import ChannelService
async def go():
# Simulate YAML parsing a numeric token/ID as an int
service = ChannelService(
channels_config={
"telegram": {"enabled": False, "bot_token": 123456789},
}
)
with caplog.at_level(logging.WARNING, logger="app.channels.service"):
await service.start()
await service.stop()
_run(go())
assert any("telegram" in r.message and r.levelno == logging.WARNING for r in caplog.records)
def test_disabled_channel_without_creds_emits_info(self, caplog):
"""Only an info log (no warning) is emitted when a channel is disabled with no credentials."""
import logging
from app.channels.service import ChannelService
async def go():
service = ChannelService(
channels_config={
"telegram": {"enabled": False},
}
)
with caplog.at_level(logging.DEBUG, logger="app.channels.service"):
await service.start()
await service.stop()
_run(go())
warning_records = [r for r in caplog.records if "telegram" in r.message and r.levelno == logging.WARNING]
assert not warning_records
# ---------------------------------------------------------------------------
# Slack send retry tests