{"record":{"id":"96646caa72b440a1","repo":"xpzouying/xiaohongshu-mcp","slug":"error-96646c","errorCode":null,"errorMessage":"查找新版发布按钮失败","messagePattern":"查找新版发布按钮失败","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"xiaohongshu/publish.go","lineNumber":484,"sourceCode":"\t\tif btn != nil && disabledReason == \"\" {\n\t\t\treturn btn, nil\n\t\t}\n\t\tif disabledReason != \"\" {\n\t\t\tlastDisabledReason = disabledReason\n\t\t}\n\t\ttime.Sleep(interval)\n\t}\n\n\tif lastDisabledReason != \"\" {\n\t\treturn nil, errors.Errorf(\"等待发布按钮可点击超时: %s\", lastDisabledReason)\n\t}\n\treturn nil, errors.New(\"等待发布按钮可点击超时\")\n}\n\nfunc findPublishButton(page *rod.Page) (*publishButton, string, error) {\n\twidgets, err := page.Elements(\"xhs-publish-btn\")\n\tif err != nil {\n\t\treturn nil, \"\", errors.Wrap(err, \"查找新版发布按钮失败\")\n\t}\n\n\tfor _, widget := range widgets {\n\t\tif !isElementVisible(widget) {\n\t\t\tcontinue\n\t\t}\n\n\t\tisPublish, err := widget.Attribute(\"is-publish\")\n\t\tif err != nil {\n\t\t\treturn nil, \"\", errors.Wrap(err, \"读取新版发布按钮 is-publish 属性失败\")\n\t\t}\n\t\tif isPublish != nil && *isPublish == \"false\" {\n\t\t\tcontinue\n\t\t}\n\n\t\tsubmitDisabled, err := widget.Attribute(\"submit-disabled\")\n\t\tif err != nil {\n\t\t\treturn nil, \"\", errors.Wrap(err, \"读取新版发布按钮 submit-disabled 属性失败\")","sourceCodeStart":466,"sourceCodeEnd":502,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/xiaohongshu/publish.go#L466-L502","documentation":"findPublishButton wraps failures from page.Elements(\"xhs-publish-btn\") with this message when querying the new-style custom publish button widget errors at the browser level. In waitForPublishButtonClickable this is logged as a warning and the loop keeps waiting rather than aborting immediately.","triggerScenarios":"The CDP/browser query for the custom element fails: page crashed, navigation in progress, or the execution context was destroyed while the SPA re-rendered.","commonSituations":"Page navigating/reloading during the query; browser tab closed by timeout; rod context cancelled mid-request.","solutions":["Usually transient — the polling loop retries automatically; just retry the whole publish if it surfaces","Ensure the page is not navigating while publish runs","Check the browser process is healthy and the tab is open","Update rod/library if execution-context errors recur after SPA updates"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"err := xhs.Publish(...)\nif err != nil && strings.Contains(err.Error(), \"查找新版发布按钮失败\") {\n    time.Sleep(time.Second)\n    err = xhs.Publish(...) // 通常是瞬时错误，重试即可\n}","preventionTips":["Avoid reloading/navigating the page during publish","Keep the browser process healthy (memory, CPU)","Rely on the library's internal polling rather than aborting on first failure","Update rod/library if context-destroyed errors recur"],"tags":["browser-automation","rod","dom-query"],"backgroundTag":"element-query-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"}