{"record":{"id":"47f938c1280e6b3e","repo":"xpzouying/xiaohongshu-mcp","slug":"s-47f938","errorCode":null,"errorMessage":"输入标签[%s]失败","messagePattern":"输入标签\\[(.+?)\\]失败","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xiaohongshu/publish.go","lineNumber":718,"sourceCode":"\t\t\treturn errors.Wrap(err, \"按下方向键失败\")\n\t\t}\n\t\ttime.Sleep(10 * time.Millisecond)\n\t}\n\n\tka, err := contentElem.KeyActions()\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"创建键盘操作失败\")\n\t}\n\tif err := ka.Press(input.Enter).Press(input.Enter).Do(); err != nil {\n\t\treturn errors.Wrap(err, \"按下回车键失败\")\n\t}\n\n\ttime.Sleep(1 * time.Second)\n\n\tfor _, tag := range tags {\n\t\ttag = strings.TrimLeft(tag, \"#\")\n\t\tif err := inputTag(ctx, contentElem, tag); err != nil {\n\t\t\treturn errors.Wrapf(err, \"输入标签[%s]失败\", tag)\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc inputTag(ctx context.Context, contentElem *rod.Element, tag string) error {\n\t// 输入 # 触发话题联想\n\tif err := humanize.Type(ctx, contentElem, \"#\"); err != nil {\n\t\treturn errors.Wrap(err, \"输入#失败\")\n\t}\n\ttime.Sleep(200 * time.Millisecond) // 技术等待：等联想下拉框弹出\n\n\tif err := humanize.Type(ctx, contentElem, tag); err != nil {\n\t\treturn errors.Wrap(err, \"输入标签内容失败\")\n\t}\n\n\ttime.Sleep(1 * time.Second) // 技术等待：等联想结果刷新\n","sourceCodeStart":700,"sourceCodeEnd":736,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/xiaohongshu/publish.go#L700-L736","documentation":"This error wraps any failure from inputTag for a specific hashtag: it names the tag in the message and propagates the underlying cause (typing '#' failed, typing tag text failed, or selection confirmation failed). inputTags stops at the first failing tag, so the publish's tag-adding step aborts with this contextual error.","triggerScenarios":"submitPublish/submitPublishVideo pass a tags list to inputTags; for tag N, inputTag fails — e.g. typing failed, the topic suggestion container (#creator-editor-topic-container) never rendered and even the space fallback failed, or the suggestion item couldn't be clicked.","commonSituations":"Tag contains characters the site's suggestion box rejects (spaces, special symbols); slow network so the suggestion dropdown doesn't appear in time; site DOM change removed the topic container; caret left the editor so typing went nowhere.","solutions":["Inspect the wrapped cause and the tag name in the message; remove or reformat problematic tags (avoid spaces/special characters, strip leading '#').","Increase waits before reading the suggestion container if the network is slow.","Verify the topic-container selector (#creator-editor-topic-container) still matches the live site DOM.","Retry the publish; transient dropdown-rendering failures often succeed on retry."],"exampleFix":"// before\ntags := []string{\"travel diary\", \"#food\", \"美食/探店\"} // problematic tags\nerr := publisher.Publish(ctx, opts)\n// after\ntags := []string{\"旅行日记\", \"美食探店\"} // clean tags; leading # stripped and invalid chars removed\nfor i := range tags {\n    tags[i] = strings.TrimLeft(strings.TrimSpace(tags[i]), \"#\")\n}\nerr := publisher.Publish(ctx, opts)","handlingStrategy":"validation","validationCode":"// sanitize tags before publish: trim, strip '#', reject unsafe chars\nvar clean []string\nfor _, t := range tags {\n    t = strings.TrimSpace(strings.TrimLeft(t, \"#\"))\n    if t == \"\" || strings.ContainsAny(t, \" /\\\\,;\") {\n        continue\n    }\n    clean = append(clean, t)\n}\nopts.Tags = clean","typeGuard":"func validTag(tag string) bool {\n    tag = strings.TrimLeft(strings.TrimSpace(tag), \"#\")\n    return tag != \"\" && !strings.ContainsFunc(tag, func(r rune) bool {\n        return r == ' ' || r == '/' || r == ','\n    })\n}","tryCatchPattern":"err := publisher.Publish(ctx, opts)\nif err != nil && strings.Contains(err.Error(), \"输入标签[\") {\n    tag := extractTag(err.Error())\n    log.Printf(\"标签 %q 输入失败，去掉该标签重试\", tag)\n    opts.Tags = removeTag(opts.Tags, tag)\n    err = publisher.Publish(ctx, opts)\n}","preventionTips":["Strip leading '#' and whitespace from tags beforehand","Avoid spaces and special characters in hashtags","Allow extra wait for the suggestion dropdown on slow networks","Verify the #creator-editor-topic-container selector against the live site"],"tags":["hashtag","typing","suggestion-dropdown","browser-automation","xiaohongshu"],"backgroundTag":"tag-input-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"}