{"record":{"id":"949a432400d9ab63","repo":"xpzouying/xiaohongshu-mcp","slug":"error-949a43","errorCode":null,"errorMessage":"未找到声明原创弹窗","messagePattern":"未找到声明原创弹窗","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xiaohongshu/publish.go","lineNumber":1049,"sourceCode":"\treturn errors.New(\"未找到原创声明选项\")\n}\n\n// confirmOriginalDeclaration 交互（勾选须知、点声明按钮）走 go-rod 点击；\n// 仅用只读 Eval 读取 checkbox 勾选态（不产生交互，无法用属性判断的自定义组件才用）。\nfunc confirmOriginalDeclaration(page *rod.Page) error {\n\ttime.Sleep(800 * time.Millisecond) // 技术等待：等确认弹窗渲染\n\n\tif footer, err := findFooterByText(page, \"原创声明须知\"); err != nil {\n\t\tslog.Warn(\"未找到原创声明确认弹窗的 footer\", \"error\", err)\n\t} else if err := checkFooterCheckbox(footer); err != nil {\n\t\tslog.Warn(\"勾选原创声明须知失败\", \"error\", err)\n\t}\n\n\ttime.Sleep(500 * time.Millisecond) // 技术等待：勾选后等\"声明原创\"按钮变可用\n\n\tfooter, err := findFooterByText(page, \"声明原创\")\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"未找到声明原创弹窗\")\n\t}\n\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","sourceCodeStart":1031,"sourceCodeEnd":1067,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/xiaohongshu/publish.go#L1031-L1067","documentation":"Thrown by confirmOriginalDeclaration when findFooterByText(page, \"声明原创\") cannot find any div.footer containing that text — the 声明原创 confirmation dialog is not on the page at that moment. The earlier 须知-footer failure is only a warning, so this is the hard failure point when the modal is missing entirely.","triggerScenarios":"The modal never opened because the toggle click did not register; the modal closed unexpectedly; XHS changed the dialog markup so its footer no longer matches div.footer; fixed sleeps elapsed before the modal rendered and rod's timeout also passed.","commonSituations":"Slow rendering environments; XHS A/B test replacing the dialog structure; the front-end silently rejecting the toggle (account not eligible for original declaration).","solutions":["Confirm the toggle actually enabled original-declaration mode (check its checkbox state) before calling confirmOriginalDeclaration.","Wait for the modal text to appear instead of fixed sleeps: page.Wait on body text containing 声明原创.","Dump page.HTML() on failure; if the dialog markup changed, update findFooterByText's div.footer selector.","Verify the account/flow actually triggers the confirmation dialog and handle a no-modal case gracefully."],"exampleFix":"// before\ntime.Sleep(500 * time.Millisecond)\nfooter, err := findFooterByText(page, \"声明原创\")\nif err != nil {\n\treturn errors.Wrap(err, \"未找到声明原创弹窗\")\n}\n// after\ntime.Sleep(500 * time.Millisecond)\nif err := page.Wait(\"() => document.body.innerText.includes('声明原创')\"); err != nil {\n\treturn errors.Wrap(err, \"声明原创弹窗未渲染\")\n}\nfooter, err := findFooterByText(page, \"声明原创\")\nif err != nil {\n\treturn errors.Wrap(err, \"未找到声明原创弹窗\")\n}","handlingStrategy":"validation","validationCode":"if err := page.Wait(\"() => document.body.innerText.includes('声明原创')\"); err != nil {\n\treturn fmt.Errorf(\"声明原创弹窗未渲染: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := setOriginal(page); err != nil {\n\tif strings.Contains(err.Error(), \"未找到声明原创弹窗\") {\n\t\thtml, _ := page.HTML()\n\t\tslog.Warn(\"original-declaration dialog missing\", \"htmlLen\", len(html))\n\t}\n\treturn err\n}","preventionTips":["Confirm the toggle registered before expecting the dialog.","Replace fixed sleeps with Wait conditions on dialog text.","If a dialog update changes the footer structure, update the div.footer selector in findFooterByText.","Handle accounts/flows that skip the confirmation dialog gracefully."],"tags":["modal-not-found","go-rod","selector-not-found","automation"],"backgroundTag":"element-selector-not-found","analyzedSha":"332d196854a9eac0d2b8c2c0e3d0cc43139d724c","analyzedAt":"2026-09-05T22:22:55.988Z","contentChangedAt":"2026-09-05T22:22:55.988Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}