{"record":{"id":"84e4cb3b31e2a9f0","repo":"xpzouying/xiaohongshu-mcp","slug":"error-84e4cb","errorCode":null,"errorMessage":"设置可见范围失败","messagePattern":"设置可见范围失败","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xiaohongshu/publish.go","lineNumber":390,"sourceCode":"\t\treturn err\n\t}\n\n\thumanize.Delay(ctx, humanize.AfterType)\n\n\tif err := checkContentMaxLength(page); err != nil {\n\t\treturn err\n\t}\n\tslog.Info(\"检查正文长度：通过\")\n\n\tif scheduleTime != nil {\n\t\tif err := setSchedulePublish(ctx, page, *scheduleTime); err != nil {\n\t\t\treturn errors.Wrap(err, \"设置定时发布失败\")\n\t\t}\n\t\tslog.Info(\"定时发布设置完成\", \"schedule_time\", scheduleTime.Format(\"2006-01-02 15:04\"))\n\t}\n\n\tif err := setVisibility(page, visibility); err != nil {\n\t\treturn errors.Wrap(err, \"设置可见范围失败\")\n\t}\n\n\t// 处理原创声明：显式请求了原创但设置失败 → 报错中止，不静默发成非原创（避免\"以为原创其实不是\"）\n\tif isOriginal {\n\t\tif err := setOriginal(page); err != nil {\n\t\t\treturn errors.Wrap(err, \"设置原创声明失败（已请求原创，中止发布）\")\n\t\t}\n\t\tslog.Info(\"已声明原创\")\n\t}\n\n\tif err := bindProducts(ctx, page, products); err != nil {\n\t\treturn errors.Wrap(err, \"绑定商品失败\")\n\t}\n\n\tif err := clickPublishButton(page); err != nil {\n\t\treturn err\n\t}\n","sourceCodeStart":372,"sourceCodeEnd":408,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/xiaohongshu/publish.go#L372-L408","documentation":"Raised in submitPublish when setVisibility fails to select the desired visibility (public/private/followers-only) on the Xiaohongshu publish form. The library wraps the underlying error so callers know the failure occurred at the visibility-selection step rather than another publish step.","triggerScenarios":"Calling Publish with a visibility value whose corresponding UI control cannot be found or clicked: the visibility selector DOM changed, the option label no longer matches, or the page element is not interactable.","commonSituations":"Xiaohongshu updated the publish page and the visibility option labels/selectors no longer match; passing an unsupported visibility constant; page not fully loaded when the step runs.","solutions":["Check the visibility value is a supported option of this library","Retry the publish; DOM timing races often pass on retry","Inspect the wrapped cause for the exact missing selector","Update the library or patch setVisibility selectors to match the current Xiaohongshu page"],"exampleFix":"// before\nerr := xhs.Publish(..., visibility=\"friends\", ...) // unsupported/renamed option\n// after\nerr := xhs.Publish(..., visibility=xhs.VisibilityPrivate, ...) // use supported constant","handlingStrategy":"validation","validationCode":"supported := map[string]bool{\"public\":true,\"private\":true,\"followers\":true}\nif !supported[visibility] {\n    return errors.Errorf(\"不支持的可见范围: %s\", visibility)\n}","typeGuard":null,"tryCatchPattern":"if err := xhs.Publish(...); err != nil {\n    if strings.Contains(err.Error(), \"设置可见范围失败\") {\n        // fall back to default visibility and retry\n    }\n}","preventionTips":["Use only visibility constants documented by the library","Retry once on transient DOM timing failures","Inspect errors.Unwrap for the missing selector","Update selectors after Xiaohongshu UI changes"],"tags":["browser-automation","rod","dom"],"backgroundTag":"visibility-select-failed","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"}