sansan0/TrendRadar · error · InvalidParameterError
INVALID_PARAMETER
INVALID_PARAMETER
Error message
无效的渠道: {invalid} What it means
Thrown by the notification tool when the caller passes channel names that are not keys of the internal _CHANNEL_REQUIREMENTS registry. The tool first checks config ENABLE_NOTIFICATION, then validates every entry in the `channels` argument against the known channel ids before dispatching. Any unknown string in the list aborts the whole send.
Source
Thrown at mcp_server/tools/notification.py:1149
"error": {"code": "EMPTY_MESSAGE", "message": "消息内容不能为空"},
}
try:
config = self._load_merged_config()
if not config.get("ENABLE_NOTIFICATION", True):
return {
"success": False,
"error": {"code": "NOTIFICATION_DISABLED", "message": "通知功能已禁用(notification.enabled = false)"},
}
# 确定目标渠道
all_channel_ids = list(_CHANNEL_REQUIREMENTS.keys())
if channels:
# 验证渠道名称
invalid = [ch for ch in channels if ch not in all_channel_ids]
if invalid:
raise InvalidParameterError(
f"无效的渠道: {invalid}",
suggestion=f"支持的渠道: {all_channel_ids}"
)
target_channels = channels
else:
# 发送到所有已配置渠道
target_channels = [
ch_id for ch_id, keys in _CHANNEL_REQUIREMENTS.items()
if all(config.get(k) for k in keys)
]
if not target_channels:
return {
"success": False,
"error": {
"code": "NO_CHANNELS",
"message": "没有已配置的目标渠道",
"suggestion": "请在 config.yaml 或 .env 中配置至少一个通知渠道",View on GitHub (pinned to 8ee26026ba)
Solutions
- Use only channel ids listed in the error's suggestion field (it prints the full _CHANNEL_REQUIREMENTS key list)
- If you want every configured channel, omit the `channels` argument entirely — the tool auto-selects channels whose required config keys are all set
- Verify the channel's required credential keys exist in config before naming it explicitly
Example fix
# before send_notification(content="deploy done", channels=["dingding"]) # after send_notification(content="deploy done", channels=["dingtalk"]) # or send to all configured channels: send_notification(content="deploy done")
Defensive patterns
Strategy: validation
Validate before calling
VALID_CHANNELS = {"wechat_work", "dingtalk", "feishu", "email"} # keep in sync with server _CHANNEL_REQUIREMENTS
def pick_channels(requested):
if not requested:
return None # let server auto-select configured channels
bad = [c for c in requested if c not in VALID_CHANNELS]
if bad:
raise ValueError(f"unknown channels {bad}; valid: {sorted(VALID_CHANNELS)}")
return requested Type guard
def is_channel_list(v) -> bool:
return v is None or (isinstance(v, list) and all(isinstance(c, str) for c in v)) Try / catch
try:
send_notification(content, channels=ch)
except InvalidParameterError as e:
if "无效的渠道" in str(e):
# parse suggestion list from error and retry with corrected channels, or send without `channels`
send_notification(content)
else:
raise Prevention
- Source the valid channel list from the server's documented schema instead of hardcoding guesses
- Omit `channels` to auto-target every fully-configured channel
- Log the error's suggestion field once and cache the valid channel set
When it happens
Trigger: Calling the send-notification MCP tool with channels=["sms"] when only ids in _CHANNEL_REQUIREMENTS exist (e.g. wechat_work, dingtalk, feishu, email); passing an empty-string or misspelled channel id; passing channels when no matching credentials are configured for that id.
Common situations: Typos in channel names ("dingding" vs "dingtalk"); assuming a channel is supported because credentials are configured; channel sets differing between deployments/versions of the server.
Related errors
AI-assisted analysis of sansan0/TrendRadar@8ee26026ba (2026-08-15).
Data as JSON: /api/errors/a6536dda0db1bd30.
Report an issue: GitHub.