xpzouying/xiaohongshu-mcp · error
设置定时发布失败
Error message
设置定时发布失败
What it means
When ScheduleTime is non-nil, submitPublishVideo calls setSchedulePublish to switch the publish form into scheduled mode and pick the date/time. Any failure is wrapped as "设置定时发布失败". It means the schedule UI could not be operated — the toggle/date-picker interaction failed.
Source
Thrown at xiaohongshu/publish_video.go:135
if err != nil {
return err
}
if err := humanize.Type(ctx, contentElem, content); err != nil {
return errors.Wrap(err, "输入正文失败")
}
if err := waitAndClickTitleInput(titleElem); err != nil {
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
}
View on GitHub (pinned to 332d196854)
Solutions
- Validate the schedule time is in the platform's allowed window (not in the past, not beyond the max horizon, adequate lead time) before calling
- Re-run with a longer timeout so the date picker has time to render
- Inspect current markup and update the schedule toggle / picker selectors
- As a workaround, publish immediately (ScheduleTime=nil) and repost later
Example fix
// before
schedule := time.Now().Add(30 * time.Second)
action.PublishVideo(ctx, PublishVideoContent{ScheduleTime: &schedule})
// after
schedule := time.Now().Add(2 * time.Hour) // well inside the allowed window
action.PublishVideo(ctx, PublishVideoContent{ScheduleTime: &schedule}) Defensive patterns
Strategy: validation
Validate before calling
now := time.Now()
if scheduleTime != nil && (scheduleTime.Before(now.Add(1*time.Hour)) || scheduleTime.After(now.Add(14*24*time.Hour))) {
return errors.New("schedule time outside allowed window")
} Try / catch
if err := setSchedulePublish(ctx, page, *scheduleTime); err != nil {
log.Printf("schedule failed (%+v), falling back to immediate publish", err)
return submitPublishVideo(ctx, page, title, content, tags, nil, visibility, products)
} Prevention
- Schedule at least ~1–2 hours in the future, within the platform's max horizon
- Wait for the date picker to render before interacting
- Keep selectors updated against the live site
- Fall back to immediate publish if scheduling is optional
When it happens
Trigger: setSchedulePublish fails because the 定时发布 toggle selector changed, the calendar popup did not render, or the requested time is outside the allowed window (e.g. platform limits scheduling to within a certain future range or minimum lead time).
Common situations: Scheduling a time too close to now or beyond the platform max horizon; site update changing the date-picker DOM; popup rendered inside an iframe/portal the selector does not search; slow render timing out the interaction.
Related errors
AI-assisted analysis of xpzouying/xiaohongshu-mcp@332d196854 (2026-09-05).
Data as JSON: /api/errors/ccee50c4fb6ab069.
Report an issue: GitHub.