xpzouying/xiaohongshu-mcp · warning
定时发布时间必须至少在1小时后,当前设置: %s,最早可选: %s
Error message
定时发布时间必须至少在1小时后,当前设置: %s,最早可选: %s
What it means
After a successful RFC3339 parse, PublishContent enforces that the scheduled publish time is at least 1 hour in the future. A ScheduleAt earlier than now+1h is rejected, echoing both the requested time and the earliest allowed time in '2006-01-02 15:04' format.
Source
Thrown at service.go:229
imagePaths, err := s.processImages(req.Images)
if err != nil {
return nil, err
}
var scheduleTime *time.Time
if req.ScheduleAt != "" {
t, err := time.Parse(time.RFC3339, req.ScheduleAt)
if err != nil {
return nil, fmt.Errorf("定时发布时间格式错误,请使用 ISO8601 格式: %v", err)
}
// 校验定时发布时间范围:1小时至14天
now := time.Now()
minTime := now.Add(1 * time.Hour)
maxTime := now.Add(14 * 24 * time.Hour)
if t.Before(minTime) {
return nil, fmt.Errorf("定时发布时间必须至少在1小时后,当前设置: %s,最早可选: %s",
t.Format("2006-01-02 15:04"), minTime.Format("2006-01-02 15:04"))
}
if t.After(maxTime) {
return nil, fmt.Errorf("定时发布时间不能超过14天,当前设置: %s,最晚可选: %s",
t.Format("2006-01-02 15:04"), maxTime.Format("2006-01-02 15:04"))
}
scheduleTime = &t
logrus.Infof("设置定时发布时间: %s", t.Format("2006-01-02 15:04"))
}
content := xiaohongshu.PublishImageContent{
Title: req.Title,
Content: req.Content,
Tags: req.Tags,
ImagePaths: imagePaths,
ScheduleTime: scheduleTime,
IsOriginal: req.IsOriginal,View on GitHub (pinned to 332d196854)
Solutions
- Set ScheduleAt to at least time.Now().Add(1*time.Hour) rounded to the minute
- Clamp the user's chosen time to minTime before calling the API, or show the earliest selectable time in the UI
- Ensure client and server timezone handling agree (prefer sending explicit UTC offsets)
Example fix
// before req.ScheduleAt = time.Now().Add(30 * time.Minute).Format(time.RFC3339) // rejected // after sched := time.Now().Add(2 * time.Hour).Truncate(time.Minute) req.ScheduleAt = sched.Format(time.RFC3339)
Defensive patterns
Strategy: validation
Validate before calling
if req.ScheduleAt != "" {
t, _ := time.Parse(time.RFC3339, req.ScheduleAt)
if min := time.Now().Add(time.Hour); t.Before(min) {
req.ScheduleAt = min.Truncate(time.Minute).Format(time.RFC3339) // clamp up
}
} Type guard
func isSchedulableAhead(t time.Time) bool {
return t.After(time.Now().Add(time.Hour))
} Try / catch
resp, err := svc.PublishContent(ctx, req)
if err != nil && strings.Contains(err.Error(), "至少在1小时后") {
return fmt.Errorf("schedule too soon: %w", err)
} Prevention
- Clamp user-chosen times to now+1h before submission
- Show the earliest selectable slot in the UI
- Send explicit timezone offsets to avoid server/local clock drift
- Account for server-vs-client clock skew (add a small buffer)
When it happens
Trigger: Calling PublishContent with a valid RFC3339 ScheduleAt that lies within the next hour (or in the past), e.g. scheduling for 10 minutes from now.
Common situations: Users picking 'publish in 30 minutes' in a UI; timezone confusion making a supposedly-future time resolve earlier than expected; testing with times close to 'now'.
Related errors
AI-assisted analysis of xpzouying/xiaohongshu-mcp@332d196854 (2026-09-05).
Data as JSON: /api/errors/dc64c85005b30317.
Report an issue: GitHub.