{"record":{"id":"9528ca01fe2dee31","repo":"xpzouying/xiaohongshu-mcp","slug":"error-9528ca","errorCode":null,"errorMessage":"输入正文失败","messagePattern":"输入正文失败","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xiaohongshu/publish_video.go","lineNumber":121,"sourceCode":"// submitPublishVideo 填写标题、正文、标签并点击发布（等待按钮可点击后再提交）\nfunc submitPublishVideo(ctx context.Context, page *rod.Page, title, content string, tags []string, scheduleTime *time.Time, visibility string, products []string) error {\n\t// 标题\n\ttitleElem, err := page.Element(\"div.d-input input\")\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"查找标题输入框失败\")\n\t}\n\tif err := humanize.Type(ctx, titleElem, title); err != nil {\n\t\treturn errors.Wrap(err, \"输入标题失败\")\n\t}\n\thumanize.Delay(ctx, humanize.AfterType)\n\n\t// 正文 + 标签\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\t// 处理定时发布\n\tif scheduleTime != nil {\n\t\tif err := setSchedulePublish(ctx, page, *scheduleTime); err != nil {\n\t\t\treturn errors.Wrap(err, \"设置定时发布失败\")\n\t\t}\n\t\tslog.Info(\"定时发布设置完成\", \"schedule_time\", scheduleTime.Format(\"2006-01-02 15:04\"))\n\t}\n","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/xiaohongshu/publish_video.go#L103-L139","documentation":"submitPublishVideo 定位到正文内容元素后 humanize.Type 填写正文（含标签）失败：contenteditable 元素失焦、被重置或输入被前端拦截。","triggerScenarios":"humanize.Type(ctx, contentElem, content) errors: element detached after re-render, ctx cancelled/deadline exceeded while typing long content, or the editable region is not focusable at typing time.","commonSituations":"Very long body text exceeding the humanize typing budget within the context deadline; editor re-render triggered by the tag section; focus stolen by a popup; page became unresponsive during long video processing.","solutions":["Extend the context deadline proportional to content length","Retry typing with a fresh element lookup on failure","Ensure the editor is focused/visible before typing (click it first)","Check content size and strip problematic characters before publishing"],"exampleFix":"// before\nif err := humanize.Type(ctx, contentElem, content); err != nil {\n    return errors.Wrap(err, \"输入正文失败\")\n}\n// after\nif err := contentElem.Click(input.Left); err != nil { return err }\nif err := humanize.Type(ctx, contentElem, content); err != nil {\n    return errors.Wrap(err, \"输入正文失败\")\n}","handlingStrategy":"retry","validationCode":"if visible, err := contentElem.Visible(); err != nil || !visible {\n    return errors.New(\"content editor not visible\")\n}","typeGuard":null,"tryCatchPattern":"if err := humanize.Type(ctx, contentElem, content); err != nil {\n    contentElem, ferr := getContentElement(page, contentElemTimeout)\n    if ferr != nil { return ferr }\n    if terr := humanize.Type(ctx, contentElem, content); terr != nil {\n        return errors.Wrap(terr, \"输入正文失败\")\n    }\n}","preventionTips":["Click/focus the editor before typing","Scale the context timeout with content length","Re-find the element on any typing failure","Sanitize content (no control chars) before publishing"],"tags":["browser-automation","go","input"],"backgroundTag":"element-detached","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"}