{"record":{"id":"718e5e9a46249d2c","repo":"xpzouying/xiaohongshu-mcp","slug":"error-718e5e","errorCode":null,"errorMessage":"发布未确认成功：点击发布后未跳转离开发布页（可能校验未过或被拦截）","messagePattern":"发布未确认成功：点击发布后未跳转离开发布页（可能校验未过或被拦截）","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xiaohongshu/publish.go","lineNumber":424,"sourceCode":"\t\treturn err\n\t}\n\n\t// 校验发布真的成功：成功后创作平台会跳转离开发布页；未跳转则判定失败，\n\t// 消除\"点了发布按钮就算成功\"的假阳性。\n\treturn waitPublishSuccess(page, 15*time.Second)\n}\n\n// waitPublishSuccess 轮询等待发布成功的信号：小红书发布成功后会跳转离开发布表单页\n// （URL 不再含 /publish/publish）。超时仍未跳转 → 判定发布失败。\nfunc waitPublishSuccess(page *rod.Page, timeout time.Duration) error {\n\tdeadline := time.Now().Add(timeout)\n\tfor {\n\t\tif info, err := page.Info(); err == nil && !strings.Contains(info.URL, \"/publish/publish\") {\n\t\t\tslog.Info(\"发布成功，已跳转离开发布页\", \"url\", info.URL)\n\t\t\treturn nil\n\t\t}\n\t\tif time.Now().After(deadline) {\n\t\t\treturn errors.New(\"发布未确认成功：点击发布后未跳转离开发布页（可能校验未过或被拦截）\")\n\t\t}\n\t\ttime.Sleep(500 * time.Millisecond)\n\t}\n}\n\ntype publishButton struct {\n\telem     *rod.Element\n\tisWidget bool\n}\n\nfunc clickPublishButton(page *rod.Page) error {\n\tbtn, err := waitForPublishButtonClickable(page, 15*time.Second)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif btn.isWidget {\n\t\treturn clickPublishWidget(page, btn.elem)","sourceCodeStart":406,"sourceCodeEnd":442,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/xiaohongshu/publish.go#L406-L442","documentation":"waitPublishSuccess polls page.Info() every 500ms until the URL no longer contains /publish/publish, treating navigation away as confirmation that the post was published. If the deadline expires while still on the publish page, it throws this error: the publish click happened but success could not be confirmed — the post may have failed validation, been rate-limited, or blocked by a toast/dialog.","triggerScenarios":"submitPublish or submitPublishVideo clicked the publish button but the SPA never navigated away within the deadline — e.g. form validation error (missing title/description), a toast like '包含违规内容', a confirmation dialog, or the click actually missed the button.","commonSituations":"Content rejected by XHS review (sensitive words, watermarked images); missing required fields; new-user rate limits; slow XHS backend exceeding the deadline; XHS changing its publish-success URL pattern.","solutions":["Check the page manually on failure — capture page screenshot/DOM to see the error toast or dialog blocking navigation","Ensure title/description meet length and content rules; missing description commonly blocks publishing","Extend the deadline if the network/XHS backend is slow; success may just be delayed","Detect in-page error toasts (e.g. .toast / error popups) instead of relying only on URL change, and surface their text in the error","Confirm the publish button click actually landed (waitForPublishButtonClickable succeeded and click reported no error)"],"exampleFix":"// before\nif time.Now().After(deadline) {\n\treturn errors.New(\"发布未确认成功：...\")\n}\n// after\nif time.Now().After(deadline) {\n\tif toast, _ := page.Element(\".toast\"); toast != nil {\n\t\tmsg, _ := toast.Text()\n\t\treturn errors.Errorf(\"发布未确认成功: 页面提示 %q\", msg)\n\t}\n\treturn errors.New(\"发布未确认成功：点击发布后未跳转离开发布页\")\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := submitPublish(page); err != nil {\n\tif strings.Contains(err.Error(), \"发布未确认成功\") {\n\t\tshot, _ := page.Screenshot(true, nil) // 留证排查：校验未过或被拦截\n\t\t_ = os.WriteFile(\"publish-fail.png\", shot, 0644)\n\t\t// 检查标题/正文是否违规或缺失后重试\n\t}\n\treturn err\n}","preventionTips":["Ensure all required fields (title, description) are filled and within length limits","Avoid sensitive/banned words that fail XHS review","Take a screenshot on failure to see blocking toasts/dialogs","Allow generous deadline on slow networks"],"tags":["timeout","navigation","publish","xiaohongshu"],"backgroundTag":"publish-navigation-not-confirmed","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"}