{"record":{"id":"24cee7b3f418e1de","repo":"xpzouying/xiaohongshu-mcp","slug":"error-24cee7","errorCode":null,"errorMessage":"设置定时发布失败","messagePattern":"设置定时发布失败","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xiaohongshu/publish.go","lineNumber":384,"sourceCode":"\t\treturn errors.Wrap(err, \"输入正文失败\")\n\t}\n\tif err := waitAndClickTitleInput(titleElem); err != nil {\n\t\treturn err\n\t}\n\tif err := inputTags(ctx, contentElem, tags); err != nil {\n\t\treturn err\n\t}\n\n\thumanize.Delay(ctx, humanize.AfterType)\n\n\tif err := checkContentMaxLength(page); err != nil {\n\t\treturn err\n\t}\n\tslog.Info(\"检查正文长度：通过\")\n\n\tif scheduleTime != nil {\n\t\tif err := setSchedulePublish(ctx, page, *scheduleTime); err != nil {\n\t\t\treturn errors.Wrap(err, \"设置定时发布失败\")\n\t\t}\n\t\tslog.Info(\"定时发布设置完成\", \"schedule_time\", scheduleTime.Format(\"2006-01-02 15:04\"))\n\t}\n\n\tif err := setVisibility(page, visibility); err != nil {\n\t\treturn errors.Wrap(err, \"设置可见范围失败\")\n\t}\n\n\t// 处理原创声明：显式请求了原创但设置失败 → 报错中止，不静默发成非原创（避免\"以为原创其实不是\"）\n\tif isOriginal {\n\t\tif err := setOriginal(page); err != nil {\n\t\t\treturn errors.Wrap(err, \"设置原创声明失败（已请求原创，中止发布）\")\n\t\t}\n\t\tslog.Info(\"已声明原创\")\n\t}\n\n\tif err := bindProducts(ctx, page, products); err != nil {\n\t\treturn errors.Wrap(err, \"绑定商品失败\")","sourceCodeStart":366,"sourceCodeEnd":402,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/xiaohongshu/publish.go#L366-L402","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)"],"exampleFix":"// before\nschedule := time.Now().Add(-1 * time.Hour) // past time\nerr := xhs.Publish(..., &schedule, ...)\n// after\nschedule := time.Now().Add(2 * time.Hour) // future, within allowed window\nif schedule.Before(time.Now()) { return errors.New(\"schedule time must be future\") }\nerr := xhs.Publish(..., &schedule, ...)","handlingStrategy":"validation","validationCode":"if scheduleTime != nil && !scheduleTime.After(time.Now()) {\n    return errors.New(\"定时发布时间必须晚于当前时间\")\n}","typeGuard":null,"tryCatchPattern":"var e *xhsError\nif err := xhs.Publish(...); err != nil {\n    if strings.Contains(err.Error(), \"设置定时发布失败\") {\n        // skip scheduling or fix scheduleTime and retry\n    }\n    _ = e\n}","preventionTips":["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"],"tags":["browser-automation","rod","dom"],"backgroundTag":"schedule-publish-failed","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"}