{"record":{"id":"dc64c85005b30317","repo":"xpzouying/xiaohongshu-mcp","slug":"1-s-s","errorCode":null,"errorMessage":"定时发布时间必须至少在1小时后，当前设置: %s，最早可选: %s","messagePattern":"定时发布时间必须至少在1小时后，当前设置: (.+?)，最早可选: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"service.go","lineNumber":229,"sourceCode":"\timagePaths, err := s.processImages(req.Images)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar scheduleTime *time.Time\n\tif req.ScheduleAt != \"\" {\n\t\tt, err := time.Parse(time.RFC3339, req.ScheduleAt)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"定时发布时间格式错误，请使用 ISO8601 格式: %v\", err)\n\t\t}\n\n\t\t// 校验定时发布时间范围：1小时至14天\n\t\tnow := time.Now()\n\t\tminTime := now.Add(1 * time.Hour)\n\t\tmaxTime := now.Add(14 * 24 * time.Hour)\n\n\t\tif t.Before(minTime) {\n\t\t\treturn nil, fmt.Errorf(\"定时发布时间必须至少在1小时后，当前设置: %s，最早可选: %s\",\n\t\t\t\tt.Format(\"2006-01-02 15:04\"), minTime.Format(\"2006-01-02 15:04\"))\n\t\t}\n\t\tif t.After(maxTime) {\n\t\t\treturn nil, fmt.Errorf(\"定时发布时间不能超过14天，当前设置: %s，最晚可选: %s\",\n\t\t\t\tt.Format(\"2006-01-02 15:04\"), maxTime.Format(\"2006-01-02 15:04\"))\n\t\t}\n\n\t\tscheduleTime = &t\n\t\tlogrus.Infof(\"设置定时发布时间: %s\", t.Format(\"2006-01-02 15:04\"))\n\t}\n\n\tcontent := xiaohongshu.PublishImageContent{\n\t\tTitle:        req.Title,\n\t\tContent:      req.Content,\n\t\tTags:         req.Tags,\n\t\tImagePaths:   imagePaths,\n\t\tScheduleTime: scheduleTime,\n\t\tIsOriginal:   req.IsOriginal,","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/service.go#L211-L247","documentation":"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.","triggerScenarios":"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.","commonSituations":"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'.","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)"],"exampleFix":"// before\nreq.ScheduleAt = time.Now().Add(30 * time.Minute).Format(time.RFC3339) // rejected\n// after\nsched := time.Now().Add(2 * time.Hour).Truncate(time.Minute)\nreq.ScheduleAt = sched.Format(time.RFC3339)","handlingStrategy":"validation","validationCode":"if req.ScheduleAt != \"\" {\n    t, _ := time.Parse(time.RFC3339, req.ScheduleAt)\n    if min := time.Now().Add(time.Hour); t.Before(min) {\n        req.ScheduleAt = min.Truncate(time.Minute).Format(time.RFC3339) // clamp up\n    }\n}","typeGuard":"func isSchedulableAhead(t time.Time) bool {\n    return t.After(time.Now().Add(time.Hour))\n}","tryCatchPattern":"resp, err := svc.PublishContent(ctx, req)\nif err != nil && strings.Contains(err.Error(), \"至少在1小时后\") {\n    return fmt.Errorf(\"schedule too soon: %w\", err)\n}","preventionTips":["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)"],"tags":["go","validation","scheduling","time-window"],"backgroundTag":"schedule-time-out-of-range","analyzedSha":"332d196854a9eac0d2b8c2c0e3d0cc43139d724c","analyzedAt":"2026-09-05T22:22:55.988Z","contentChangedAt":"2026-09-05T22:22:55.988Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}