{"record":{"id":"7776ef9dd47efb7a","repo":"xpzouying/xiaohongshu-mcp","slug":"error-7776ef","errorCode":null,"errorMessage":"输入标题失败","messagePattern":"输入标题失败","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xiaohongshu/publish_video.go","lineNumber":111,"sourceCode":"\n\t// 对于视频，等待发布按钮变为可点击即表示处理完成\n\tbtn, err := waitForPublishButtonClickable(pp, 10*time.Minute)\n\tif err != nil {\n\t\treturn err\n\t}\n\tslog.Info(\"视频上传/处理完成，发布按钮可点击\", \"btn\", btn)\n\treturn nil\n}\n\n// 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","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/xiaohongshu/publish_video.go#L93-L129","documentation":"After finding the title element, submitPublishVideo types the title via humanize.Type (simulated human keystrokes). If that returns an error it is wrapped as \"输入标题失败\". Typically the element became stale/detached or the context was cancelled mid-typing.","triggerScenarios":"humanize.Type(ctx, titleElem, title) fails because the element was removed/re-rendered between lookup and typing, ctx deadline exceeded, or the underlying rod input events error out (element not visible, page navigated).","commonSituations":"Page re-renders the editor right after element lookup (auto-focus redraw); ctx timeout too short for human-speed typing of a long title; modal (e.g. login prompt) steals focus; empty or oversized title rejected by an inline handler.","solutions":["Re-lookup the element immediately before typing, or wrap typing in a retry that re-finds the element","Extend the context deadline to allow for human-paced typing","Ensure no overlay/dialog intercepts input — dismiss popups first","Validate title length/content before calling"],"exampleFix":"// before\nif err := humanize.Type(ctx, titleElem, title); err != nil {\n    return errors.Wrap(err, \"输入标题失败\")\n}\n// after\nfor i := 0; i < 2; i++ {\n    titleElem, err = page.Element(\"div.d-input input\")\n    if err == nil && humanize.Type(ctx, titleElem, title) == nil {\n        break\n    }\n}","handlingStrategy":"retry","validationCode":"if visible, err := titleElem.Visible(); err != nil || !visible {\n    return errors.New(\"title input not visible for typing\")\n}","typeGuard":null,"tryCatchPattern":"if err := humanize.Type(ctx, titleElem, title); err != nil {\n    titleElem, ferr := page.Element(\"div.d-input input\") // re-find stale element\n    if ferr != nil { return ferr }\n    if terr := humanize.Type(ctx, titleElem, title); terr != nil {\n        return errors.Wrap(terr, \"输入标题失败\")\n    }\n}","preventionTips":["Re-lookup elements right before interacting with them","Budget context deadlines generously for human-paced typing","Dismiss any overlays/dialogs before typing","Keep titles within platform length limits"],"tags":["browser-automation","go","input","timeout"],"backgroundTag":"element-detached","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"}