{"record":{"id":"ccffefbebaf18ce0","repo":"sansan0/TrendRadar","slug":"invalid-parameter-ccffef","errorCode":"INVALID_PARAMETER","errorMessage":"无效的搜索模式: {search_mode}","messagePattern":"无效的搜索模式: (.+?)","errorType":"error_code","errorClass":"InvalidParameterError","httpStatus":null,"severity":"error","filePath":"mcp_server/tools/search_tools.py","lineNumber":83,"sourceCode":"            include_rss: 是否同时搜索RSS数据，默认False\n            rss_limit: RSS返回条数限制，默认20\n\n        Returns:\n            搜索结果字典，包含匹配的新闻列表（热榜和RSS分开展示）\n\n        Examples:\n            - search_news_unified(query=\"人工智能\", search_mode=\"keyword\")\n            - search_news_unified(query=\"特斯拉降价\", search_mode=\"fuzzy\", threshold=0.4)\n            - search_news_unified(query=\"马斯克\", search_mode=\"entity\", limit=20)\n            - search_news_unified(query=\"AI\", include_rss=True)  # 同时搜索热榜和RSS\n            - search_news_unified(query=\"iPhone 16\", date_range={\"start\": \"2025-01-01\", \"end\": \"2025-01-07\"})\n        \"\"\"\n        try:\n            # 参数验证\n            query = validate_keyword(query)\n\n            if search_mode not in [\"keyword\", \"fuzzy\", \"entity\"]:\n                raise InvalidParameterError(\n                    f\"无效的搜索模式: {search_mode}\",\n                    suggestion=\"支持的模式: keyword, fuzzy, entity\"\n                )\n\n            if sort_by not in [\"relevance\", \"weight\", \"date\"]:\n                raise InvalidParameterError(\n                    f\"无效的排序方式: {sort_by}\",\n                    suggestion=\"支持的排序: relevance, weight, date\"\n                )\n\n            limit = validate_limit(limit, default=50)\n            threshold = validate_threshold(threshold, default=0.6, min_value=0.0, max_value=1.0)\n\n            # 处理日期范围\n            if date_range:\n                from ..utils.validators import validate_date_range\n                date_range_tuple = validate_date_range(date_range)\n                start_date, end_date = date_range_tuple","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/sansan0/TrendRadar/blob/8ee26026ba6c11dec41a95fb3895a7162876caa1/mcp_server/tools/search_tools.py#L65-L101","documentation":"Thrown by search_news_unified when the search_mode argument is not one of the three supported modes: keyword, fuzzy, entity. The check runs right after keyword validation and before any query execution, so no search happens when it fires.","triggerScenarios":"Calling search_news_unified with search_mode=\"semantic\", \"match\", \"regex\", or any string outside [\"keyword\", \"fuzzy\", \"entity\"]; passing a mode from a different tool's vocabulary.","commonSituations":"LLM agents guessing mode names; copying mode values from another search API; case sensitivity issues (\"Keyword\" is rejected — the check is exact-match).","solutions":["Set search_mode to exactly one of: keyword, fuzzy, entity","For approximate matching use fuzzy together with threshold (default 0.6, range 0.0–1.0)","For named-entity based search (e.g. person/company names) use entity"],"exampleFix":"# before\nsearch_news_unified(query=\"AI\", search_mode=\"semantic\")\n\n# after\nsearch_news_unified(query=\"AI\", search_mode=\"fuzzy\", threshold=0.4)","handlingStrategy":"validation","validationCode":"SEARCH_MODES = {\"keyword\", \"fuzzy\", \"entity\"}\nsearch_mode = search_mode if search_mode in SEARCH_MODES else \"keyword\"","typeGuard":"def is_search_mode(v) -> bool:\n    return isinstance(v, str) and v in {\"keyword\", \"fuzzy\", \"entity\"}","tryCatchPattern":"try:\n    search_news_unified(query=q, search_mode=mode)\nexcept InvalidParameterError as e:\n    if \"搜索模式\" in str(e):\n        return search_news_unified(query=q, search_mode=\"keyword\")  # safe fallback\n    raise","preventionTips":["Pin an enum in your tool schema so LLM callers cannot emit free text","Default search_mode explicitly rather than letting agents invent values","Remember values are case-sensitive exact matches"],"tags":["search","validation","mcp-tools"],"backgroundTag":null,"analyzedSha":"8ee26026ba6c11dec41a95fb3895a7162876caa1","analyzedAt":"2026-08-15T01:42:18.084Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}