{"record":{"id":"21fd61df7f2ff2cd","repo":"xpzouying/xiaohongshu-mcp","slug":"error-21fd61","errorCode":null,"errorMessage":"确认原创声明失败","messagePattern":"确认原创声明失败","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xiaohongshu/publish.go","lineNumber":1024,"sourceCode":"\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\n\t\tif checked.Value.Bool() {\n\t\t\tslog.Info(\"原创声明已开启\")\n\t\t\treturn nil\n\t\t}\n\n\t\t// 点击开关\n\t\tif err := humanize.Click(switchElem); err != nil {\n\t\t\treturn errors.Wrap(err, \"点击原创声明开关失败\")\n\t\t}\n\n\t\ttime.Sleep(500 * time.Millisecond)\n\n\t\t// 处理原创声明确认弹窗\n\t\tif err := confirmOriginalDeclaration(page); err != nil {\n\t\t\treturn errors.Wrap(err, \"确认原创声明失败\")\n\t\t}\n\n\t\tslog.Info(\"已开启原创声明\")\n\t\treturn nil\n\t}\n\n\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)","sourceCodeStart":1006,"sourceCodeEnd":1042,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/xiaohongshu/publish.go#L1006-L1042","documentation":"Thrown by setOriginal wrapping any failure from confirmOriginalDeclaration — the follow-up modal flow after toggling original declaration. The 须知-footer lookup inside confirmOriginalDeclaration is only logged as a warning, so this error almost always means the 声明原创 confirmation footer/button was not found or the button stayed disabled.","triggerScenarios":"The confirmation modal never rendered (toggle click had no effect); the modal rendered with different footer markup so findFooterByText(\"声明原创\") missed it; the 须知 checkbox was not checked so the confirm button remained disabled.","commonSituations":"XHS redesigning the confirm dialog structure; modal render slower than the fixed 800ms+500ms sleeps; the div.d-checkbox selector failing silently so the button stays disabled.","solutions":["Replace fixed sleeps with waits for the modal to actually render and the checkbox to be checked.","Verify checkFooterCheckbox succeeded before expecting the button to enable.","Dump page.HTML() after the toggle click to confirm the modal exists and update footer/button selectors.","Re-run the flow manually in a browser to observe the current modal DOM after an XHS update."],"exampleFix":"// before\ntime.Sleep(800 * time.Millisecond)\nfooter, err := findFooterByText(page, \"原创声明须知\")\n// after\ntime.Sleep(800 * time.Millisecond)\nif err := page.Wait(\"() => document.body.innerText.includes('声明原创')\"); err != nil {\n\treturn errors.Wrap(err, \"确认弹窗未渲染\")\n}\nfooter, err := findFooterByText(page, \"原创声明须知\")","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := setOriginal(page); err != nil {\n\tif strings.Contains(err.Error(), \"确认原创声明失败\") {\n\t\t// 弹窗可能未及时渲染：等待后重试一次\n\t\t_ = page.Wait(\"() => document.body.innerText.includes('声明原创')\")\n\t\ttime.Sleep(1 * time.Second)\n\t\treturn setOriginal(page)\n\t}\n\treturn err\n}","preventionTips":["Wait for modal text to appear rather than trusting fixed 800/500ms sleeps.","Confirm the 须知 checkbox got checked before expecting the confirm button to enable.","Log and inspect page HTML when the confirm flow fails to catch XHS dialog redesigns.","Verify the toggle took effect before invoking the confirm step."],"tags":["modal-confirm-failed","go-rod","automation","selector-not-found"],"backgroundTag":"modal-confirmation-flow-failed","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"}