{"record":{"id":"c1a42cd5d17b3d88","repo":"xpzouying/xiaohongshu-mcp","slug":"s-c1a42c","errorCode":null,"errorMessage":"查找正文输入框失败: %s","messagePattern":"查找正文输入框失败: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xiaohongshu/publish.go","lineNumber":674,"sourceCode":"\n\tfor {\n\t\telem, err := findContentElement(page)\n\t\tif err == nil {\n\t\t\treturn elem, nil\n\t\t}\n\n\t\tif time.Now().After(deadline) {\n\t\t\treturn nil, errors.Wrap(err, \"查找正文输入框失败\")\n\t\t}\n\t\ttime.Sleep(300 * time.Millisecond)\n\t}\n}\n\nfunc findContentElement(page *rod.Page) (*rod.Element, error) {\n\tfor _, selector := range contentElemSelectors {\n\t\telems, err := page.Elements(selector)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrapf(err, \"查找正文输入框失败: %s\", selector)\n\t\t}\n\n\t\tfor _, elem := range elems {\n\t\t\tif isElementVisible(elem) {\n\t\t\t\treturn elem, nil\n\t\t\t}\n\t\t}\n\t}\n\n\treturn findTextboxByPlaceholder(page)\n}\n\nfunc inputTags(ctx context.Context, contentElem *rod.Element, tags []string) error {\n\tif len(tags) == 0 {\n\t\treturn nil\n\t}\n\n\ttime.Sleep(1 * time.Second)","sourceCodeStart":656,"sourceCodeEnd":692,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/xiaohongshu/publish.go#L656-L692","documentation":"This error is wrapped by findContentElement when page.Elements(selector) itself fails for one of the content-element candidate selectors (e.g. invalid selector or CDP query error). Unlike a mere 'not found' result, this indicates the DOM query call errored, and the selector that failed is included in the message. getContentElement keeps polling and eventually wraps this as '查找正文输入框失败' if it never recovers.","triggerScenarios":"During publish, findContentElement iterates contentElemSelectors; a call to page.Elements returns an error — commonly due to an invalid selector string, a detached/closed page, or browser connection failure.","commonSituations":"Malformed selector after hand-editing contentElemSelectors; browser/tab closed mid-run; rod browser process crashed; CDP connection dropped.","solutions":["Check the wrapped cause and the selector in the message; verify the selector syntax is valid CSS.","Ensure the browser page is still open and connected (not navigated away or closed).","Restart the browser session and retry the publish.","If a selector is obsolete/broken, remove or fix it in contentElemSelectors."],"exampleFix":"// before\n`div[role=\"textbox\"][contenteditable=\"true\"]`, // ok\n`div.tiptap[contenteditable=true]`, // invalid: unquoted attribute value\n// after\n`div[role=\"textbox\"][contenteditable=\"true\"]`,\n`div.tiptap[contenteditable=\"true\"]`,","handlingStrategy":"fallback","validationCode":"// sanity-check selectors are valid CSS before the flow runs\nfor _, sel := range selectors {\n    if _, err := page.Elements(sel); err != nil {\n        log.Printf(\"无效选择器 %s: %v\", sel, err)\n    }\n}","typeGuard":null,"tryCatchPattern":"err := publisher.Publish(ctx, opts)\nif err != nil && strings.Contains(err.Error(), \"查找正文输入框失败: \") {\n    sel := extractSelector(err.Error())\n    log.Printf(\"选择器查询出错: %s，请检查浏览器连接\", sel)\n    // reconnect browser / reopen page, then retry\n}","preventionTips":["Validate all selectors as proper CSS (quote attribute values)","Keep the browser process and tab alive for the whole flow","Monitor CDP connection health; reconnect on drop","Remove obsolete selectors from the candidate list"],"tags":["dom","selector","cdp","browser-automation","xiaohongshu"],"backgroundTag":"dom-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"}