xpzouying/xiaohongshu-mcp · error
无法输入回复内容: %w
Error message
无法输入回复内容: %w
What it means
humanize.Type failed while typing the reply into the comment input, e.g. because the element lost focus, was detached, or the simulated keystrokes errored. Content was non-empty (validated earlier), so this is a UI-interaction failure, not a validation failure.
Source
Thrown at xiaohongshu/notification_reply.go:73
}
humanize.Delay(ctx, humanize.BeforeClick)
if err := humanize.Click(replyBtn); err != nil {
return nil, fmt.Errorf("无法点击回复: %w", err)
}
humanize.Delay(ctx, humanize.AfterClick)
input, err := item.Element(`textarea.comment-input`)
if err != nil {
return nil, fmt.Errorf("回复输入框未出现: %w", err)
}
if err := verifyReplyTarget(input, target.from().Nickname); err != nil {
return nil, err
}
if err := humanize.Type(ctx, input, content); err != nil {
return nil, fmt.Errorf("无法输入回复内容: %w", err)
}
humanize.Delay(ctx, humanize.AfterType)
submit, err := item.Element(`button.submit`)
if err != nil {
return nil, fmt.Errorf("未找到发送按钮: %w", err)
}
humanize.Delay(ctx, humanize.BeforeSubmit)
if err := humanize.Click(submit); err != nil {
return nil, fmt.Errorf("无法点击发送: %w", err)
}
if err := waitReplyAccepted(item, 8*time.Second); err != nil {
return nil, err
}
humanize.Delay(ctx, humanize.AfterInteract)View on GitHub (pinned to 332d196854)
Solutions
- Retry the call; transient focus issues usually clear on retry
- Shorten the reply content — long humanized typing increases the race window
- Check ctx deadlines — ensure the context is not cancelled mid-typing
- Keep the browser window focused (headful mode) or use headless mode consistently
Defensive patterns
Strategy: retry
Validate before calling
if ctx.Err() != nil {
return fmt.Errorf("context expired before reply: %w", ctx.Err())
} Try / catch
_, err := n.Reply(ctx, commentID, content)
if err != nil && strings.Contains(err.Error(), "无法输入回复内容") {
time.Sleep(2 * time.Second)
_, err = n.Reply(ctx, commentID, content)
} Prevention
- Use a context with enough budget for humanized typing
- Keep reply texts reasonably short
- Avoid focus competition in headful browsers
When it happens
Trigger: humanize.Type(ctx, input, content) returns an error during Reply — textarea detached after re-render, focus stolen by popup, or ctx cancelled mid-typing.
Common situations: Page re-render replaced the textarea mid-type; browser tab lost focus in headful mode; context deadline exceeded during slow humanized typing of long content; anti-bot input interception.
Related errors
AI-assisted analysis of xpzouying/xiaohongshu-mcp@332d196854 (2026-09-05).
Data as JSON: /api/errors/c79aace76733dad8.
Report an issue: GitHub.