xpzouying/xiaohongshu-mcp · warning
定时发布时间格式错误,请使用 ISO8601 格式: %v
Error message
定时发布时间格式错误,请使用 ISO8601 格式: %v
What it means
PublishContent parses req.ScheduleAt with time.Parse(time.RFC3339, ...). If the string is not a valid RFC3339/ISO8601 timestamp, publishing is rejected with this error before any scheduling occurs. The wrapped %v contains the underlying parse error.
Source
Thrown at service.go:220
}
// PublishContent 发布内容
func (s *XiaohongshuService) PublishContent(ctx context.Context, req *PublishRequest) (*PublishResponse, error) {
// 验证标题长度(小红书限制:最大20个字)
if xhsutil.CalcTitleLength(req.Title) > 20 {
return nil, fmt.Errorf("标题长度超过限制")
}
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"))View on GitHub (pinned to 332d196854)
Solutions
- Send ScheduleAt in RFC3339 format, e.g. '2026-09-06T10:00:00+08:00' or '...Z'
- On the caller side, parse/convert the user's input with time.Parse(time.RFC3339) first and show a format hint
- Normalize common formats (space-separated, no timezone) to RFC3339 before calling the API
Example fix
// before req.ScheduleAt = "2026-09-06 10:00:00" // parse error // after req.ScheduleAt = time.Date(2026, 9, 6, 10, 0, 0, 0, time.Local).Format(time.RFC3339)
Defensive patterns
Strategy: validation
Validate before calling
if req.ScheduleAt != "" {
if _, err := time.Parse(time.RFC3339, req.ScheduleAt); err != nil {
return fmt.Errorf("ScheduleAt must be RFC3339, got %q", req.ScheduleAt)
}
} Type guard
func isRFC3339(s string) bool {
_, err := time.Parse(time.RFC3339, s)
return err == nil
} Try / catch
resp, err := svc.PublishContent(ctx, req)
if err != nil && strings.Contains(err.Error(), "ISO8601") {
return fmt.Errorf("bad schedule format: %w — use e.g. %s", err, time.Now().Add(2*time.Hour).Format(time.RFC3339))
} Prevention
- Always serialize times with t.Format(time.RFC3339)
- Never hand-format datetimes with spaces or missing timezone offsets
- Add a client-side isRFC3339 check before invoking the service
- Document the expected format in the API schema (format: date-time)
When it happens
Trigger: Calling PublishContent with ScheduleAt set to any non-RFC3339 string, e.g. '2026-09-06 10:00:00' (space instead of T), '2026/09/06', missing timezone offset, or Unix epoch numbers.
Common situations: Frontend sending local datetime strings without 'T' separator or timezone; serializing with a non-ISO format; users typing times manually; JavaScript toISOString vs local formatting mismatches.
Related errors
AI-assisted analysis of xpzouying/xiaohongshu-mcp@332d196854 (2026-09-05).
Data as JSON: /api/errors/66013b3fa7633a0c.
Report an issue: GitHub.