{"record":{"id":"0d2b0f497f607212","repo":"xpzouying/xiaohongshu-mcp","slug":"error-0d2b0f","errorCode":null,"errorMessage":"输入正文失败","messagePattern":"输入正文失败","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xiaohongshu/publish.go","lineNumber":366,"sourceCode":"\t}\n\tif err := humanize.Type(ctx, titleElem, title); err != nil {\n\t\treturn errors.Wrap(err, \"输入标题失败\")\n\t}\n\n\thumanize.Delay(ctx, humanize.AfterType)\n\tif err := checkTitleMaxLength(page); err != nil {\n\t\treturn err\n\t}\n\tslog.Info(\"检查标题长度：通过\")\n\n\thumanize.Delay(ctx, humanize.AfterType)\n\n\tcontentElem, err := getContentElement(page, contentElemTimeout)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif err := humanize.Type(ctx, contentElem, content); err != nil {\n\t\treturn errors.Wrap(err, \"输入正文失败\")\n\t}\n\tif err := waitAndClickTitleInput(titleElem); err != nil {\n\t\treturn err\n\t}\n\tif err := inputTags(ctx, contentElem, tags); err != nil {\n\t\treturn err\n\t}\n\n\thumanize.Delay(ctx, humanize.AfterType)\n\n\tif err := checkContentMaxLength(page); err != nil {\n\t\treturn err\n\t}\n\tslog.Info(\"检查正文长度：通过\")\n\n\tif scheduleTime != nil {\n\t\tif err := setSchedulePublish(ctx, page, *scheduleTime); err != nil {\n\t\t\treturn errors.Wrap(err, \"设置定时发布失败\")","sourceCodeStart":348,"sourceCodeEnd":384,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/xiaohongshu/publish.go#L348-L384","documentation":"After typing the title, submitPublish fetches the content (正文) editor via getContentElement and types the body text with humanize.Type. A failure during that typing is wrapped as '输入正文失败'. The content editor is a rich-text area, so failures usually come from the editor being stale, covered, or rendered differently than expected.","triggerScenarios":"humanize.Type(ctx, contentElem, content) erroring in submitPublish (xiaohongshu/publish.go:366), after getContentElement already succeeded.","commonSituations":"Rich-text editor re-rendered after clicking the title input (waitAndClickTitleInput) invalidating the element handle; empty/oversized content; an editor toolbar popup or suggestion dropdown intercepts keystrokes; very long content slows typing past internal timeouts; CDP disconnect mid-typing.","solutions":["Retry Publish once — rich-text editors often re-render and a fresh run succeeds","Confirm content is non-empty and within the length limit (checkContentMaxLength runs after typing, but pre-validate yourself)","Screenshot at failure to check for popups/suggestions covering the editor","Increase content-element timeout passed to getContentElement if the editor loads slowly","Keep browser/CDP session healthy; avoid concurrent operations on the same page during typing"],"exampleFix":"// before\nif err := humanize.Type(ctx, contentElem, content); err != nil {\n    return errors.Wrap(err, \"输入正文失败\")\n}\n// after\nif err := humanize.Type(ctx, contentElem, content); err != nil {\n    return errors.Wrap(err, \"输入正文失败\") // 建议调用侧重试一次并截图排查编辑器遮挡\n}","handlingStrategy":"try-catch","validationCode":"if strings.TrimSpace(content) == \"\" { return errors.New(\"正文不能为空\") }\nif len([]rune(content)) > 1000 { return errors.New(\"正文过长, 请精简\") }","typeGuard":null,"tryCatchPattern":"err := bot.Publish(ctx, post, images)\nif err != nil && strings.Contains(err.Error(), \"输入正文失败\") {\n    // 重试一次; 仍失败则截图检查富文本编辑器状态\n}","preventionTips":["Pre-validate content length against Xiaohongshu's limit","Retry once — editors often re-render after title click","Watch for editor suggestion popups intercepting keystrokes","Keep the browser/CDP session stable during typing"],"tags":["humanize","typing","rich-text-editor","browser-automation"],"backgroundTag":"element-interaction-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"}