{"record":{"id":"edeafb7d6a19f8f7","repo":"xpzouying/xiaohongshu-mcp","slug":"error-edeafb","errorCode":null,"errorMessage":"点击声明原创按钮失败","messagePattern":"点击声明原创按钮失败","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xiaohongshu/publish.go","lineNumber":1069,"sourceCode":"\n\tbtn, err := footer.Element(\"button.custom-button\")\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"未找到声明原创按钮\")\n\t}\n\n\tif isButtonDisabled(btn) {\n\t\t// 兜底：按钮仍禁用，可能须知未勾上，再勾一次\n\t\tif err := checkFooterCheckbox(footer); err != nil {\n\t\t\tslog.Warn(\"二次勾选须知失败\", \"error\", err)\n\t\t}\n\t\ttime.Sleep(300 * time.Millisecond)\n\t\tif isButtonDisabled(btn) {\n\t\t\treturn errors.New(\"声明原创按钮仍处于禁用状态\")\n\t\t}\n\t}\n\n\tif err := humanize.Click(btn); err != nil {\n\t\treturn errors.Wrap(err, \"点击声明原创按钮失败\")\n\t}\n\tslog.Info(\"已成功点击声明原创按钮\")\n\ttime.Sleep(300 * time.Millisecond)\n\treturn nil\n}\n\nfunc findFooterByText(page *rod.Page, keyword string) (*rod.Element, error) {\n\tfooters, err := page.Elements(\"div.footer\")\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"查找弹窗 footer 失败\")\n\t}\n\tfor _, footer := range footers {\n\t\ttext, err := footer.Text()\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\t\tif strings.Contains(text, keyword) {\n\t\t\treturn footer, nil","sourceCodeStart":1051,"sourceCodeEnd":1087,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/xiaohongshu/publish.go#L1051-L1087","documentation":"confirmOriginalDeclaration wraps a humanize.Click failure on the '声明原创' (declare original) button with this message. The button was found and appeared enabled, but the simulated click itself failed (element detached, intercepted, or CDP action error). It indicates a DOM instability or overlay issue at click time, not a missing button.","triggerScenarios":"The confirm-originality dialog's footer button was located but humanize.Click failed: the dialog re-rendered between isButtonDisabled check and click, an overlay/toast covers the button, or the rod page/browser context was lost mid-click.","commonSituations":"Slow page rendering on the Xiaohongshu publish flow causing mid-click DOM replacement; the '须知' checkbox click silently failed so UI state shifted; headless environments where animation timing differs.","solutions":["Retry confirmOriginalDeclaration once after a short delay; transient detach often resolves","Check logs for the preceding '勾选原创声明须知失败' warning — fix checkbox selection so the button stays stable","Increase waits before clicking (the 300/500ms sleeps) or use rod's WaitStable/WaitVisible on the button","Verify the page/browser wasn't closed or navigated by another goroutine"],"exampleFix":"// before\nif err := humanize.Click(btn); err != nil {\n    return errors.Wrap(err, \"点击声明原创按钮失败\")\n}\n// after\nif err := btn.WaitVisible(); err != nil { return err }\nif err := btn.WaitStable(); err != nil { return err }\nif err := humanize.Click(btn); err != nil {\n    return errors.Wrap(err, \"点击声明原创按钮失败\")\n}","handlingStrategy":"retry","validationCode":"// before calling the publish flow\nif page == nil { return errors.New(\"page is nil\") }\nif _, err := page.Info(); err != nil { return fmt.Errorf(\"page not alive: %w\", err) }","typeGuard":null,"tryCatchPattern":"for attempt := 0; attempt < 3; attempt++ {\n    err := confirmOriginalDeclaration(page)\n    if err == nil || !strings.Contains(err.Error(), \"点击声明原创按钮失败\") { break }\n    time.Sleep(time.Second)\n}","preventionTips":["Wait for the button to be stable/visible before clicking instead of fixed sleeps","Fix checkbox selection first so the button state doesn't shift mid-click","Keep the page open and avoid concurrent navigation during publish","Log the inner error to distinguish detach vs overlay vs closed page"],"tags":["go-rod","dom-click","automation"],"backgroundTag":"rod-click-element-detached","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"}