{"record":{"id":"75a3b94a00c532c0","repo":"xpzouying/xiaohongshu-mcp","slug":"error-75a3b9","errorCode":null,"errorMessage":"点击标签联想选项失败","messagePattern":"点击标签联想选项失败","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xiaohongshu/publish.go","lineNumber":751,"sourceCode":"\t}\n\n\ttime.Sleep(1 * time.Second) // 技术等待：等联想结果刷新\n\n\tpage := contentElem.Page()\n\ttopicContainer, err := page.Element(\"#creator-editor-topic-container\")\n\tif err != nil || topicContainer == nil {\n\t\tslog.Warn(\"未找到标签联想下拉框，直接输入空格\", \"tag\", tag)\n\t\treturn humanize.Type(ctx, contentElem, \" \")\n\t}\n\n\tfirstItem, err := topicContainer.Element(\".item\")\n\tif err != nil || firstItem == nil {\n\t\tslog.Warn(\"未找到标签联想选项，直接输入空格\", \"tag\", tag)\n\t\treturn humanize.Type(ctx, contentElem, \" \")\n\t}\n\n\tif err := humanize.Click(firstItem); err != nil {\n\t\treturn errors.Wrap(err, \"点击标签联想选项失败\")\n\t}\n\tslog.Info(\"成功点击标签联想选项\", \"tag\", tag)\n\ttime.Sleep(500 * time.Millisecond) // 技术等待：等标签处理完成\n\treturn nil\n}\n\nfunc findTextboxByPlaceholder(page *rod.Page) (*rod.Element, error) {\n\telements, err := page.Elements(\"p\")\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"查找正文候选元素失败\")\n\t}\n\tif len(elements) == 0 {\n\t\treturn nil, errors.New(\"no p elements found\")\n\t}\n\n\tplaceholderElem := findPlaceholderElement(elements, \"输入正文描述\")\n\tif placeholderElem == nil {\n\t\treturn nil, errors.New(\"no placeholder element found\")","sourceCodeStart":733,"sourceCodeEnd":769,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/xiaohongshu/publish.go#L733-L769","documentation":"inputTag wraps failure from humanize.Click on the first topic-autocomplete item. The dropdown appeared and an option was found, but clicking it failed. This means the automation could not complete the tag selection click on the suggestion item.","triggerScenarios":"The suggestion item was found but detached/re-rendered before the click landed; the click was intercepted by an overlay; CDP click timed out; the dropdown closed between element search and click.","commonSituations":"Slow network to the browser causing the 1s autocomplete refresh window to be insufficient; UI A/B changes move or re-render the topic container; concurrent automation on the same page steals focus.","solutions":["Call WaitStable on firstItem before humanize.Click.","Increase the post-'#' wait (currently 1s) before locating the option.","Fall back to typing a space (the code already does this when no option is found) — wrap the whole flow with a retry that does that fallback on click failure too.","Re-query the option element immediately before clicking."],"exampleFix":"// before\nif err := humanize.Click(firstItem); err != nil {\n    return errors.Wrap(err, \"点击标签联想选项失败\")\n}\n// after\nif err := firstItem.WaitStable(200 * time.Millisecond); err == nil {\n    if err := humanize.Click(firstItem); err != nil {\n        return humanize.Type(ctx, contentElem, \" \") // 降级：直接输入空格结束标签\n    }\n}","handlingStrategy":"fallback","validationCode":"if err := firstItem.WaitStable(200 * time.Millisecond); err != nil { firstItem = nil } // 视为未找到，走空格降级","typeGuard":"func clickable(e *rod.Element) bool { return e != nil && e.WaitStable(200*time.Millisecond) == nil }","tryCatchPattern":"if err := humanize.Click(firstItem); err != nil {\n    slog.Warn(\"点击联想选项失败，输入空格降级\", \"tag\", tag)\n    return humanize.Type(ctx, contentElem, \" \")\n}","preventionTips":["Use WaitStable before clicking dynamic suggestion items","Keep the autocomplete wait configurable","Prefer the space-fallback path over failing the whole publish"],"tags":["browser-automation","rod","xhs-publish"],"backgroundTag":"cdp-click-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"}