xpzouying/xiaohongshu-mcp · error
设置定时发布失败
Error message
设置定时发布失败
What it means
This wrapper error is raised in submitPublish when setSchedulePublish fails to configure a scheduled (timed) publish on the Xiaohongshu upload page. The library wraps the underlying DOM interaction error with this message so the caller knows the failure happened specifically during the schedule-time step of publishing, after content validation passed.
Source
Thrown at xiaohongshu/publish.go:384
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 err := checkContentMaxLength(page); err != nil {
return err
}
slog.Info("检查正文长度:通过")
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 isOriginal {
if err := setOriginal(page); err != nil {
return errors.Wrap(err, "设置原创声明失败(已请求原创,中止发布)")
}
slog.Info("已声明原创")
}
if err := bindProducts(ctx, page, products); err != nil {
return errors.Wrap(err, "绑定商品失败")View on GitHub (pinned to 332d196854)
Solutions
- Validate scheduleTime is in the future and within Xiaohongshu's allowed scheduling window before calling Publish
- Retry Publish; transient page-load timing issues often resolve on a second attempt
- Log and inspect the wrapped cause (errors.Unwrap) to see the underlying DOM failure
- Update the library if Xiaohongshu changed the publish page DOM (scheduler selectors)
Example fix
// before
schedule := time.Now().Add(-1 * time.Hour) // past time
err := xhs.Publish(..., &schedule, ...)
// after
schedule := time.Now().Add(2 * time.Hour) // future, within allowed window
if schedule.Before(time.Now()) { return errors.New("schedule time must be future") }
err := xhs.Publish(..., &schedule, ...) Defensive patterns
Strategy: validation
Validate before calling
if scheduleTime != nil && !scheduleTime.After(time.Now()) {
return errors.New("定时发布时间必须晚于当前时间")
} Try / catch
var e *xhsError
if err := xhs.Publish(...); err != nil {
if strings.Contains(err.Error(), "设置定时发布失败") {
// skip scheduling or fix scheduleTime and retry
}
_ = e
} Prevention
- Always pass future schedule times within the platform's allowed window
- Pre-validate scheduleTime before calling Publish
- Log the wrapped cause chain for diagnosis
- Keep the library updated for DOM changes
When it happens
Trigger: Calling Publish with a non-nil scheduleTime pointer while setSchedulePublish fails: the schedule toggle/calendar DOM elements are missing or changed, the schedule time is in the past or outside the allowed window, or the browser page context is invalid.
Common situations: Passing a scheduleTime that is earlier than now (Xiaohongshu rejects past times), a time beyond the platform's max scheduling horizon, an outdated page DOM after a Xiaohongshu frontend update, or the page navigating away mid-flow.
Related errors
AI-assisted analysis of xpzouying/xiaohongshu-mcp@332d196854 (2026-09-05).
Data as JSON: /api/errors/24cee7b3f418e1de.
Report an issue: GitHub.