{"record":{"id":"c0471194555dfbc9","repo":"xpzouying/xiaohongshu-mcp","slug":"14-s-s","errorCode":null,"errorMessage":"定时发布时间不能超过14天，当前设置: %s，最晚可选: %s","messagePattern":"定时发布时间不能超过14天，当前设置: (.+?)，最晚可选: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"service.go","lineNumber":233,"sourceCode":"\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,\n\t\tVisibility:   req.Visibility,\n\t\tProducts:     req.Products,\n\t}\n","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/service.go#L215-L251","documentation":"PublishContent also caps scheduled publish times at 14 days into the future. A valid RFC3339 ScheduleAt later than now+14d is rejected, echoing the requested time and the latest allowed time. Both bounds are enforced in local server time at validation moment.","triggerScenarios":"Calling PublishContent with ScheduleAt more than 14*24h after now, e.g. scheduling a post for next month.","commonSituations":"Users scheduling content weeks ahead; UI date pickers without a max-date constraint; DST/timezone shifts pushing a near-14-day time just past the limit.","solutions":["Cap the scheduled time at time.Now().Add(14*24*time.Hour) before calling the API","Constrain the frontend date picker's max date to 14 days ahead","If a longer lead time is needed, poll/queue locally and publish when within the 14-day window"],"exampleFix":"// before\nreq.ScheduleAt = time.Now().AddDate(0, 1, 0).Format(time.RFC3339) // 1 month ahead\n// after\nmax := time.Now().Add(14 * 24 * time.Hour)\nsched := time.Now().AddDate(0, 0, 13)\nif sched.After(max) { sched = max }\nreq.ScheduleAt = sched.Format(time.RFC3339)","handlingStrategy":"validation","validationCode":"if req.ScheduleAt != \"\" {\n    t, _ := time.Parse(time.RFC3339, req.ScheduleAt)\n    if max := time.Now().Add(14 * 24 * time.Hour); t.After(max) {\n        return fmt.Errorf(\"schedule must be within 14 days, latest %s\", max.Format(time.RFC3339))\n    }\n}","typeGuard":"func isWithin14Days(t time.Time) bool {\n    return t.Before(time.Now().Add(14 * 24 * time.Hour))\n}","tryCatchPattern":"resp, err := svc.PublishContent(ctx, req)\nif err != nil && strings.Contains(err.Error(), \"不能超过14天\") {\n    return fmt.Errorf(\"schedule too far out: %w\", err)\n}","preventionTips":["Cap date pickers' max date at now+14 days","Validate the upper bound in the same client-side check as the lower bound","For longer lead times, implement a local queue that publishes when the date is within range","Recheck bounds right before submission since time advances between validation and call"],"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"}