xpzouying/xiaohongshu-mcp · error
设置可见范围失败
Error message
设置可见范围失败
What it means
setVisibility switches the publish form's visibility (公开可见/仅自己可见/仅互关好友可见). A failure is wrapped as "设置可见范围失败" — the visibility control could not be found or clicked. An empty/unknown visibility string can also make the matching option lookup fail.
Source
Thrown at xiaohongshu/publish_video.go:142
return err
}
if err := inputTags(ctx, contentElem, tags); err != nil {
return err
}
humanize.Delay(ctx, humanize.AfterType)
// 处理定时发布
if scheduleTime != nil {
if err := setSchedulePublish(ctx, page, *scheduleTime); err != nil {
return errors.Wrap(err, "设置定时发布失败")
}
slog.Info("定时发布设置完成", "schedule_time", scheduleTime.Format("2006-01-02 15:04"))
}
// 设置可见范围
if err := setVisibility(page, visibility); err != nil {
return errors.Wrap(err, "设置可见范围失败")
}
// 绑定商品
if err := bindProducts(ctx, page, products); err != nil {
return errors.Wrap(err, "绑定商品失败")
}
if err := clickPublishButton(page); err != nil {
return err
}
// 校验发布真的成功(成功跳转离开发布页),未跳转判失败——消除假成功
return waitPublishSuccess(page, 15*time.Second)
}
View on GitHub (pinned to 332d196854)
Solutions
- Pass exactly one of the supported strings: "公开可见", "仅自己可见", "仅互关好友可见" (empty defaults to 公开可见)
- Inspect the live page and update the visibility selectors in setVisibility
- Add a wait for the visibility control to be visible/clickable before interacting
- Omit Visibility (empty string) if the default public scope is acceptable
Example fix
// before
action.PublishVideo(ctx, PublishVideoContent{Visibility: "private"})
// after
action.PublishVideo(ctx, PublishVideoContent{Visibility: "仅自己可见"}) Defensive patterns
Strategy: validation
Validate before calling
var allowed = map[string]bool{"": true, "公开可见": true, "仅自己可见": true, "仅互关好友可见": true}
if !allowed[visibility] {
return fmt.Errorf("unsupported visibility %q", visibility)
} Try / catch
if err := setVisibility(page, visibility); err != nil {
log.Printf("visibility setup failed: %+v, continuing with default", err)
// proceed or return wrapped — choose explicitly
} Prevention
- Only pass the exact supported Chinese label strings
- Leave Visibility empty to accept the default 公开可见
- Wait for the dropdown to be open before selecting an option
- Re-verify selectors after site updates
When it happens
Trigger: setVisibility(page, visibility) fails because the visibility dropdown/option selector does not match current markup, the label string is not one of the three exact supported values, or the control is hidden until some other step completes.
Common situations: Passing an unexpected value like "public" or "private" instead of the exact Chinese labels; frontend update renaming the option elements; dropdown rendered but option list not open when clicked.
Related errors
AI-assisted analysis of xpzouying/xiaohongshu-mcp@332d196854 (2026-09-05).
Data as JSON: /api/errors/57bdde12cdbcbc67.
Report an issue: GitHub.