{"record":{"id":"96be755e44a2e7ed","repo":"sansan0/TrendRadar","slug":"error-96be75","errorCode":null,"errorMessage":"日期查询字符串不能为空","messagePattern":"日期查询字符串不能为空","errorType":"validation","errorClass":"InvalidParameterError","httpStatus":null,"severity":"warning","filePath":"mcp_server/utils/validators.py","lineNumber":654,"sourceCode":"    Args:\n        date_query: 日期查询字符串\n        allow_future: 是否允许未来日期\n        max_days_ago: 允许查询的最大天数\n\n    Returns:\n        解析后的datetime对象\n\n    Raises:\n        InvalidParameterError: 日期查询无效\n\n    Examples:\n        >>> validate_date_query(\"昨天\")\n        datetime(2025, 10, 10)\n        >>> validate_date_query(\"2025-10-10\")\n        datetime(2025, 10, 10)\n    \"\"\"\n    if not date_query:\n        raise InvalidParameterError(\n            \"日期查询字符串不能为空\",\n            suggestion=\"请提供日期查询，如：今天、昨天、2025-10-10\"\n        )\n\n    # 使用DateParser解析日期\n    parsed_date = DateParser.parse_date_query(date_query)\n\n    # 验证日期不在未来\n    if not allow_future:\n        DateParser.validate_date_not_future(parsed_date)\n\n    # 验证日期不太久远\n    DateParser.validate_date_not_too_old(parsed_date, max_days=max_days_ago)\n\n    return parsed_date\n\n","sourceCodeStart":636,"sourceCodeEnd":671,"githubUrl":"https://github.com/sansan0/TrendRadar/blob/8ee26026ba6c11dec41a95fb3895a7162876caa1/mcp_server/utils/validators.py#L636-L671","documentation":"Raised by validate_date_query when the date query argument is empty (empty string or equivalent falsy value). The validator accepts natural-language Chinese dates ('今天', '昨天') and standard date strings ('2025-10-10'); before any parsing it requires a non-empty query.","triggerScenarios":"Calling a date-filtered MCP tool with date_query=\"\", date_query=None-like empty string, or omitting the value in a way that the client fills with \"\".","commonSituations":"An MCP client builds a date filter from an optional template variable that resolves to empty; LLM tool-call omits the argument and a wrapper substitutes \"\" instead of dropping the parameter.","solutions":["Provide a concrete query: natural language ('昨天') or a date string ('2025-10-10').","If the filter is optional on your side, omit the parameter entirely instead of sending an empty string.","In client wrappers, convert empty user input into parameter omission."],"exampleFix":"# before\ntool_call(date_query=\"\")\n\n# after\ntool_call(date_query=\"昨天\")\n# or omit date_query entirely if not needed","handlingStrategy":"validation","validationCode":"if not date_query or not date_query.strip():\n    # omit the filter entirely rather than sending \"\"\n    tool_call(...)\nelse:\n    tool_call(date_query=date_query.strip())","typeGuard":"def is_nonempty_date_query(v) -> bool:\n    return isinstance(v, str) and bool(v.strip())","tryCatchPattern":"try:\n    tool_call(date_query=q)\nexcept InvalidParameterError as e:\n    if \"不能为空\" in str(e):\n        tool_call()  # retry without the date filter","preventionTips":["Map empty/optional user input to parameter omission in client wrappers.","Pre-validate supported formats: natural language (今天/昨天) or YYYY-MM-DD."],"tags":["validation","mcp","date","empty-input"],"backgroundTag":null,"analyzedSha":"8ee26026ba6c11dec41a95fb3895a7162876caa1","analyzedAt":"2026-08-15T01:42:18.084Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}