{"record":{"id":"cd8957125888250e","repo":"sansan0/TrendRadar","slug":"mode-cd8957","errorCode":null,"errorMessage":"无效的模式: {mode}","messagePattern":"无效的模式: (.+?)","errorType":"validation","errorClass":"InvalidParameterError","httpStatus":null,"severity":"error","filePath":"mcp_server/utils/validators.py","lineNumber":554,"sourceCode":"    Args:\n        mode: 模式字符串\n        valid_modes: 有效模式列表\n        default: 默认模式\n\n    Returns:\n        验证后的模式\n\n    Raises:\n        InvalidParameterError: 模式无效\n    \"\"\"\n    if mode is None:\n        return default\n\n    if not isinstance(mode, str):\n        raise InvalidParameterError(\"mode 必须是字符串类型\")\n\n    if mode not in valid_modes:\n        raise InvalidParameterError(\n            f\"无效的模式: {mode}\",\n            suggestion=f\"支持的模式: {', '.join(valid_modes)}\"\n        )\n\n    return mode\n\n\ndef validate_config_section(section: Optional[str]) -> str:\n    \"\"\"\n    验证配置节参数\n\n    Args:\n        section: 配置节名称\n\n    Returns:\n        验证后的配置节\n\n    Raises:","sourceCodeStart":536,"sourceCodeEnd":572,"githubUrl":"https://github.com/sansan0/TrendRadar/blob/8ee26026ba6c11dec41a95fb3895a7162876caa1/mcp_server/utils/validators.py#L536-L572","documentation":"Raised by validate_mode when the mode string is not a member of the caller-supplied valid_modes set. This is a membership failure, not a type failure — the value is a str but not one of the allowed mode names. The error message embeds the invalid value and the suggestion lists the supported modes.","triggerScenarios":"Calling a tool with mode=\"aggressive\" when valid_modes={\"fast\",\"normal\",\"deep\"}; using a mode name from an older/newer version of the API; typos or casing mismatches such as mode=\"Fast\".","commonSituations":"Version drift: the set of supported modes changed between releases and stale client code sends a removed name. Copy-pasting a mode from docs of a different tool. Locale/case confusion ('Fast' vs 'fast').","solutions":["Read the suggestion field in the error: it lists every supported mode; pick one of those.","Update the MCP server/client to matching versions so the mode list is consistent.","Check for typos and case sensitivity in the mode string.","Omit mode to fall back to the default rather than guessing names."],"exampleFix":"# before\nmode = \"aggressive\"  # not supported\n\n# after\nmode = \"deep\"  # from suggestion: 支持的模式: fast, normal, deep","handlingStrategy":"validation","validationCode":"VALID_MODES = {\"fast\", \"normal\", \"deep\"}  # sync with tool schema\nif mode not in VALID_MODES:\n    mode = \"normal\"  # or raise locally with a clear message\ntool_call(mode=mode)","typeGuard":"def is_known_mode(v, valid_modes: set) -> bool:\n    return v is None or (isinstance(v, str) and v in valid_modes)","tryCatchPattern":"try:\n    tool_call(mode=mode)\nexcept InvalidParameterError as e:\n    # suggestion lists supported modes; parse or hardcode fallback\n    mode = \"normal\"\n    tool_call(mode=mode)","preventionTips":["Pin the mode list from the tool's schema and validate before calling.","After upgrading the MCP server, re-fetch tool schemas — mode sets change between versions."],"tags":["validation","mcp","enum","mode"],"backgroundTag":null,"analyzedSha":"8ee26026ba6c11dec41a95fb3895a7162876caa1","analyzedAt":"2026-08-15T01:42:18.084Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}