{"record":{"id":"34ecfb9e63433045","repo":"xpzouying/xiaohongshu-mcp","slug":"w-34ecfb","errorCode":null,"errorMessage":"无法输入评论内容: %w","messagePattern":"无法输入评论内容: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xiaohongshu/comment_feed.go","lineNumber":61,"sourceCode":"\t\tlogrus.Warnf(\"Failed to find comment input box: %v\", err)\n\t\treturn fmt.Errorf(\"未找到评论输入框，该帖子可能不支持评论或网页端不可访问: %w\", err)\n\t}\n\n\tif err := humanize.Click(elem); err != nil {\n\t\tlogrus.Warnf(\"Failed to click comment input box: %v\", err)\n\t\treturn fmt.Errorf(\"无法点击评论输入框: %w\", err)\n\t}\n\thumanize.Delay(ctx, humanize.AfterClick)\n\n\telem2, err := page.Element(\"div.input-box div.content-edit p.content-input\")\n\tif err != nil {\n\t\tlogrus.Warnf(\"Failed to find comment input field: %v\", err)\n\t\treturn fmt.Errorf(\"未找到评论输入区域: %w\", err)\n\t}\n\n\tif err := humanize.Type(ctx, elem2, content); err != nil {\n\t\tlogrus.Warnf(\"Failed to input comment content: %v\", err)\n\t\treturn fmt.Errorf(\"无法输入评论内容: %w\", err)\n\t}\n\n\thumanize.Delay(ctx, humanize.AfterType)\n\n\tsubmitButton, err := page.Element(\"div.bottom button.submit\")\n\tif err != nil {\n\t\tlogrus.Warnf(\"Failed to find submit button: %v\", err)\n\t\treturn fmt.Errorf(\"未找到提交按钮: %w\", err)\n\t}\n\n\tif err := humanize.Click(submitButton); err != nil {\n\t\tlogrus.Warnf(\"Failed to click submit button: %v\", err)\n\t\treturn fmt.Errorf(\"无法点击提交按钮: %w\", err)\n\t}\n\n\thumanize.Delay(ctx, humanize.AfterClick)\n\n\t// 就地校验：提交后评论应在评论区渲染出现；未出现则判定失败，避免假成功。","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/xiaohongshu/comment_feed.go#L43-L79","documentation":"PostComment 在点击评论输入框并定位到 p.content-input 后，humanize.Type 模拟人工输入评论内容失败：元素在输入过程中失焦、被重渲染，或页面拦截了键盘事件。","triggerScenarios":"humanize.Type fails because the editor element was replaced mid-typing, an overlay stole focus, or content triggered client-side length/format guards that clear input.","commonSituations":"Very long comments or ones with special characters/emoji the editor handles oddly; page rerendered by XHS during typing (e.g. suggestions popup); slow environment where keystroke timing outpaces the page.","solutions":["Retry the operation; transient focus loss often succeeds on a second run","Shorten the comment or strip unusual characters/emoji","Slow down typing / increase humanize delays for slow environments","Verify the account is not restricted (restricted accounts can open but not type/submit)"],"exampleFix":"// before\ncontent := strings.Repeat(\"好\", 500) // overly long\nclickErr := svc.PostComment(ctx, feedID, content)\n// after\ncontent := \"非常好，支持！\"\nerr := svc.PostComment(ctx, feedID, content)\nif err != nil { /* retry once with same content */ }","handlingStrategy":"retry","validationCode":"if utf8.RuneCountInString(content) > 200 || strings.Contains(content, \"http\") {\n    return errors.New(\"评论内容过长或含链接，易触发输入/过滤问题\")\n}","typeGuard":null,"tryCatchPattern":"var err error\nfor i := 0; i < 2; i++ {\n    if err = svc.PostComment(ctx, feedID, content); err == nil || !strings.Contains(err.Error(), \"无法输入评论内容\") {\n        break\n    }\n    time.Sleep(2 * time.Second)\n}","preventionTips":["控制评论长度，避免特殊字符/emoji 堆砌","慢网络下调慢 humanize 打字节奏","疑似风控时停止重试，避免加重限制"],"tags":["input","typing","dom","go-rod","comment"],"backgroundTag":"input-typing-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"}