{"record":{"id":"23927283a99dd5dd","repo":"xpzouying/xiaohongshu-mcp","slug":"s-q-s","errorCode":null,"errorMessage":"%s 不支持 %q，可选：%s","messagePattern":"(.+?) 不支持 %q，可选：(.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xiaohongshu/search.go","lineNumber":76,"sourceCode":"\tgroup  string // 组标签\n\toption string // 选项文本\n}\n\n// collectFilters 把入参展开成待应用的筛选项，顺便校验取值。\n//\n// 校验放在这里是为了在打开浏览器之前就挡掉写错的值——否则要等导航、悬停、\n// 在面板里找不到之后才能报错，等于为了说一句\"你写错了\"先向平台发一次请求。\nfunc collectFilters(filters []FilterOption) ([]pendingFilter, error) {\n\tvar pending []pendingFilter\n\n\tfor _, f := range filters {\n\t\tfor _, g := range filterGroups {\n\t\t\tvalue := g.pick(f)\n\t\t\tif value == \"\" {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif !slices.Contains(g.allowed, value) {\n\t\t\t\treturn nil, fmt.Errorf(\"%s 不支持 %q，可选：%s\",\n\t\t\t\t\tg.label, value, strings.Join(g.allowed, \"、\"))\n\t\t\t}\n\t\t\tpending = append(pending, pendingFilter{group: g.label, option: value})\n\t\t}\n\t}\n\n\treturn pending, nil\n}\n\ntype SearchAction struct {\n\tpage *rod.Page\n}\n\nfunc NewSearchAction(page *rod.Page) *SearchAction {\n\tpp := page.Timeout(60 * time.Second)\n\n\treturn &SearchAction{page: pp}\n}","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/xiaohongshu/search.go#L58-L94","documentation":"collectFilters() validates every non-empty field of FilterOption against each filter group's allowed list before any browser navigation happens. Passing a value that is not one of the exact allowed Chinese option strings for that group returns this error, naming the group label, the bad value, and the allowed options.","triggerScenarios":"Search(ctx, keyword, FilterOption{...}) with e.g. SortBy=\"likes\" (English) instead of \"最多点赞\", NoteType=\"image\" instead of \"图文\", PublishTime=\"7d\" instead of \"一周内\", or extra whitespace/case variants in any field.","commonSituations":"LLM/tool callers generating English filter values; mapping from another API's enum without translating to the exact Chinese strings; typos like \"最多点赞\"; using deprecated option names after the allowed list was updated.","solutions":["Use exactly the allowed strings shown in the error: 排序依据∈{综合,最新,最多点赞,最多评论,最多收藏}; 笔记类型∈{不限,视频,图文}; 发布时间∈{不限,一天内,一周内,半年内}; 搜索范围∈{不限,已看过,未看过,已关注}; 位置距离∈{不限,同城,附近}","Omit the field entirely (empty string) instead of passing \"不限\" if you mean the default","Trim whitespace and avoid any case/variant mapping before constructing FilterOption","Wrap filter construction in a small mapper that validates against the same enum lists"],"exampleFix":"// before\nFilterOption{SortBy: \"likes\", PublishTime: \"7d\"}\n// after\nFilterOption{SortBy: \"最多点赞\", PublishTime: \"一周内\"}","handlingStrategy":"validation","validationCode":"var allowed = map[string][]string{\n    \"sort_by\":      {\"综合\", \"最新\", \"最多点赞\", \"最多评论\", \"最多收藏\"},\n    \"note_type\":    {\"不限\", \"视频\", \"图文\"},\n    \"publish_time\": {\"不限\", \"一天内\", \"一周内\", \"半年内\"},\n    \"search_scope\": {\"不限\", \"已看过\", \"未看过\", \"已关注\"},\n    \"location\":     {\"不限\", \"同城\", \"附近\"},\n}\nfunc check(k, v string) error {\n    if v == \"\" || slices.Contains(allowed[k], v) { return nil }\n    return fmt.Errorf(\"%s 不支持 %q，可选：%v\", k, v, allowed[k])\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass the exact Chinese option strings; never map English enums directly","Omit fields (leave empty) rather than passing \"不限\" for defaults","Centralize FilterOption construction in one helper with validation","Keep this validation in sync with the library's filterGroups if you fork it"],"tags":["validation","go","search","invalid-argument"],"backgroundTag":"invalid-filter-option","analyzedSha":"332d196854a9eac0d2b8c2c0e3d0cc43139d724c","analyzedAt":"2026-09-05T22:22:55.988Z","contentChangedAt":"2026-09-05T22:22:55.988Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}