sansan0/TrendRadar · error · ValueError
不支持的传输模式: {transport}
Error message
不支持的传输模式: {transport} What it means
Raised by Scheduler._validate_hhmm when a time string does not match the strict two-digit 'HH:MM' pattern (regex ^\d{2}:\d{2}$). The scheduler config expects times like '09:30', not '9:30', '0930', '9:30:00', or '09-30'. This is a ValueError thrown during config validation before any scheduling starts.
Source
Thrown at mcp_server/server.py:1215
print(" 24. get_channel_format_guide - 获取渠道格式化策略指南(提示词)")
print(" 25. get_notification_channels - 获取已配置的通知渠道状态")
print(" 26. send_notification - 向通知渠道发送消息(自动适配格式)")
print("=" * 60)
print()
# 根据传输模式运行服务器
if transport == 'stdio':
mcp.run(transport='stdio')
elif transport == 'http':
# HTTP 模式(生产推荐)
mcp.run(
transport='http',
host=host,
port=port,
path='/mcp' # HTTP 端点路径
)
else:
raise ValueError(f"不支持的传输模式: {transport}")
if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser(
description='TrendRadar MCP Server - 新闻热点聚合 MCP 工具服务器',
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog="""
详细配置教程请查看: README-Cherry-Studio.md
"""
)
parser.add_argument(
'--transport',
choices=['stdio', 'http'],
default='stdio',
help='传输模式:stdio (默认) 或 http (生产环境)'
)View on GitHub (pinned to 8ee26026ba)
Solutions
- Fix the offending value to zero-padded HH:MM, e.g. '9:30' -> '09:30'.
- If the value comes from a script, format it with f'{h:02d}:{m:02d}' or datetime.strptime(...).strftime('%H:%M') before passing it to the scheduler.
- Add a config-schema check (e.g. pydantic validator or JSON Schema pattern '^([01]\d|2[0-3]):[0-5]\d$') so mistakes are caught at config load with a clearer message.
- Audit all time fields in the config file, since one bad field usually means siblings may share the same formatting mistake.
Example fix
# before
quiet_hours = {"start": "9:00", "end": "23:00"}
# after
quiet_hours = {"start": "09:00", "end": "23:00"}
# or generate safely
start = f"{9:02d}:00" # '09:00' Defensive patterns
Strategy: validation
Validate before calling
import re
HHMM_RE = re.compile(r"^\d{2}:\d{2}$")
def is_hhmm_shape(value: str) -> bool:
return bool(HHMM_RE.match(value))
# before loading scheduler config
for name, t in config_times.items():
if not is_hhmm_shape(t):
raise ConfigError(f"{name}='{t}' must be HH:MM, e.g. '09:30'") Type guard
def is_hhmm(value: str) -> bool:
"""True only for strings like '09:30' (shape checked; range see is_valid_hhmm)."""
return isinstance(value, str) and bool(re.match(r"^\d{2}:\d{2}$", value)) Prevention
- Always format times with strftime('%H:%M') or f'{h:02d}:{m:02d}' instead of string concatenation.
- Add a regex pattern to your config schema so mistakes fail at load time with a field name.
- Add unit tests over representative boundary values ('00:00', '23:59', '9:30', '24:00') when touching scheduler config code.
When it happens
Trigger: Passing a time window string to scheduler config (e.g. quiet_hours or scheduled push windows) that is not exactly 5 characters 'NN:NN'. Examples producing it: '9:00' (missing leading zero), '09:00:00' (seconds included), '0900' (no colon), '09:3O' (letter O), or a full ISO datetime '2024-01-01T09:00'.
Common situations: Hand-edited YAML/JSON config files with times typed without zero-padding; times copied from ISO 8601 timestamps; environment variables overriding defaults with a differently formatted time; UI or script generating times via str(int(hour)) which drops the leading zero.
Related errors
- DATA_NOT_FOUND
- 未知的预设模板: '{preset}',可选值: {', '.join(presets.keys())}, custom
- timeline 缺少必须字段: {key}
- week_map 缺少星期映射: {day}
- week_map[{day}] 引用了不存在的 day_plan: {plan_key}
AI-assisted analysis of sansan0/TrendRadar@8ee26026ba (2026-08-15).
Data as JSON: /api/errors/9cde6231de752b82.
Report an issue: GitHub.