{"record":{"id":"d4eb34a6f6a8ffa1","repo":"sansan0/TrendRadar","slug":"join-invalid-platforms","errorCode":null,"errorMessage":"不支持的平台: {', '.join(invalid_platforms)}","messagePattern":"不支持的平台: (.+?)","errorType":"validation","errorClass":"InvalidParameterError","httpStatus":null,"severity":"error","filePath":"mcp_server/utils/validators.py","lineNumber":249,"sourceCode":"            # 空字符串或解析后为空，使用默认平台\n            return supported_platforms if supported_platforms else []\n\n    if not isinstance(platforms, list):\n        raise InvalidParameterError(\"platforms 参数必须是列表类型\")\n\n    if not platforms:\n        # 空列表时，返回配置文件中的平台列表\n        return supported_platforms if supported_platforms else []\n\n    # 如果配置加载失败（supported_platforms为空），允许所有平台通过\n    if not supported_platforms:\n        print(\"警告：平台配置未加载，跳过平台验证\")\n        return platforms\n\n    # 验证每个平台是否在配置中\n    invalid_platforms = [p for p in platforms if p not in supported_platforms]\n    if invalid_platforms:\n        raise InvalidParameterError(\n            f\"不支持的平台: {', '.join(invalid_platforms)}\",\n            suggestion=f\"支持的平台（来自config.yaml）: {', '.join(supported_platforms)}\"\n        )\n\n    return platforms\n\n\ndef validate_limit(limit: Optional[Union[int, str]], default: int = 20, max_limit: int = 1000) -> int:\n    \"\"\"\n    验证数量限制参数\n\n    Args:\n        limit: 限制数量（整数或字符串）\n        default: 默认值\n        max_limit: 最大限制\n\n    Returns:\n        验证后的限制值","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/sansan0/TrendRadar/blob/8ee26026ba6c11dec41a95fb3895a7162876caa1/mcp_server/utils/validators.py#L231-L267","documentation":"Raised when every entry in the platforms list was validated against supported_platforms (loaded from config.yaml) and at least one entry is not present. The suggestion enumerates the exact configured platform names, so mismatches are usually spelling or a stale config.","triggerScenarios":"Calling a tool with platforms: [\"twitter\"] when config.yaml only defines e.g. weibo/wechat; case mismatches like [\"Weibo\"]; renamed platforms after a config change. Note: if config loading failed entirely (supported_platforms empty), validation is skipped with a printed warning instead — so this error specifically means config loaded and the name is wrong.","commonSituations":"Typo'd or capitalized platform keys; using platform names from an older project version; config.yaml edited but server not restarted; copying example invocations from docs of a different deployment.","solutions":["Use one of the exact names listed in the suggestion (they come straight from config.yaml), matching case exactly","Check config.yaml for the canonical platform identifiers and correct your call","Restart/redeploy the MCP server after editing config.yaml so supported_platforms is reloaded","If the platform genuinely should exist, add its entry to config.yaml and reload"],"exampleFix":"// before\n{\"platforms\": [\"Twitter\", \"weibo\"]}\n// after\n{\"platforms\": [\"weibo\"]}","handlingStrategy":"validation","validationCode":"const CONFIGURED = new Set(['weibo', 'wechat']); // mirror config.yaml\nconst safe = platforms.filter(p => CONFIGURED.has(p));\nif (!safe.length) safe = undefined; // or use defaults","typeGuard":"const isSupportedPlatform = (p: string): boolean => CONFIGURED.has(p);","tryCatchPattern":"try { call({ platforms }); }\ncatch (e) {\n  const m = e.message.match(/支持的平台（来自config.yaml）: (.+)/);\n  if (m) call({ platforms: m[1].split(', ') }); // adopt server's list and retry\n  else throw e;\n}","preventionTips":["Fetch/copy the platform list from config.yaml once and hardcode a client-side whitelist","Match platform identifiers exactly (case-sensitive)","Restart the server after config.yaml changes and re-sync your whitelist"],"tags":["platforms","config","validation"],"backgroundTag":null,"analyzedSha":"8ee26026ba6c11dec41a95fb3895a7162876caa1","analyzedAt":"2026-08-15T01:42:18.084Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}