{"record":{"id":"9b968455f3548858","repo":"xpzouying/xiaohongshu-mcp","slug":"s-9b9684","errorCode":null,"errorMessage":"未找到可见范围选项: %s","messagePattern":"未找到可见范围选项: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xiaohongshu/publish.go","lineNumber":916,"sourceCode":"\topts, err := page.Elements(\"div.d-options-wrapper div.d-grid-item div.custom-option\")\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"查找可见范围选项失败\")\n\t}\n\tfor _, opt := range opts {\n\t\ttext, err := opt.Text()\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\t\tif strings.Contains(text, visibility) {\n\t\t\tif err := humanize.Click(opt); err != nil {\n\t\t\t\treturn errors.Wrap(err, \"选择可见范围失败\")\n\t\t\t}\n\t\t\tslog.Info(\"已设置可见范围\", \"visibility\", visibility)\n\t\t\ttime.Sleep(200 * time.Millisecond)\n\t\t\treturn nil\n\t\t}\n\t}\n\treturn errors.Errorf(\"未找到可见范围选项: %s\", visibility)\n}\n\n// setSchedulePublish 设置定时发布时间\nfunc setSchedulePublish(ctx context.Context, page *rod.Page, t time.Time) error {\n\t// 1. 点击定时发布开关\n\tif err := clickScheduleSwitch(page); err != nil {\n\t\treturn err\n\t}\n\ttime.Sleep(800 * time.Millisecond)\n\n\t// 2. 设置日期时间\n\tif err := setDateTime(ctx, page, t); err != nil {\n\t\treturn err\n\t}\n\ttime.Sleep(500 * time.Millisecond)\n\n\treturn nil\n}","sourceCodeStart":898,"sourceCodeEnd":934,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/xiaohongshu/publish.go#L898-L934","documentation":"setVisibility returns this when the dropdown opened and options were listed, but none of the option texts contained the requested visibility string. The value passed validation (194) yet isn't present as an option in the actual UI popup, so the requested visibility cannot be applied.","triggerScenarios":"Visibility value valid per the map (e.g. \"仅互关好友可见\") but the current account/page doesn't offer that option (account type restrictions); option text changed/renamed in the UI; popup listed different options for video vs article publish flow.","commonSituations":"Enterprise or restricted accounts lacking 仅互关好友可见; Xiaohongshu renaming option labels; caller passing a substring that doesn't match rendered text.","solutions":["Log the collected option texts on failure so you can compare against the requested value.","Verify the value against the actual UI options for your account type.","Update the matching logic/labels if the UI text changed.","Fall back to a safe default (公开可见) or fail the publish early with a clear message."],"exampleFix":"// before\nreturn errors.Errorf(\"未找到可见范围选项: %s\", visibility)\n// after\nvar found []string\nfor _, o := range opts { if t, _ := o.Text(); t != \"\" { found = append(found, t) } }\nreturn errors.Errorf(\"未找到可见范围选项: %s, 可用选项: %v\", visibility, found)","handlingStrategy":"fallback","validationCode":"// 调用前无法完全预知 UI 选项，建议先读取选项文本核对\nopts, _ := page.Elements(\"div.d-options-wrapper div.d-grid-item div.custom-option\")\nfor _, o := range opts { t, _ := o.Text(); slog.Debug(\"可选范围\", \"option\", t) }","typeGuard":"func visibilityOffered(opts []*rod.Element, want string) bool {\n    for _, o := range opts { if t, err := o.Text(); err == nil && strings.Contains(t, want) { return true } }\n    return false\n}","tryCatchPattern":"if err := setVisibility(page, visibility); err != nil {\n    if strings.Contains(err.Error(), \"未找到可见范围选项\") {\n        slog.Warn(\"目标可见范围不可用，回退公开可见\")\n        return setVisibility(page, \"公开可见\")\n    }\n    return err\n}","preventionTips":["Log available option texts when matching fails","Confirm the account type offers the requested visibility","Provide a safe default fallback in the publish flow"],"tags":["browser-automation","ui-mismatch","xhs-publish"],"backgroundTag":"option-not-found","analyzedSha":"332d196854a9eac0d2b8c2c0e3d0cc43139d724c","analyzedAt":"2026-09-05T22:22:55.988Z","contentChangedAt":"2026-09-05T22:22:55.988Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}