{"record":{"id":"da480b93f5f198f2","repo":"xpzouying/xiaohongshu-mcp","slug":"d-d-da480b","errorCode":null,"errorMessage":"通知条目渲染数(%d)少于目标位置(%d)，页面可能未加载完","messagePattern":"通知条目渲染数\\((.+?)\\)少于目标位置\\((.+?)\\)，页面可能未加载完","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xiaohongshu/notification_reply.go","lineNumber":46,"sourceCode":"\t\treturn nil, fmt.Errorf(\"回复内容不能为空\")\n\t}\n\n\tpage := n.page.Timeout(3 * time.Minute)\n\n\tpage.MustNavigate(\"https://www.xiaohongshu.com/notification\").MustWaitLoad()\n\thumanize.Delay(ctx, humanize.AfterNavigate)\n\n\ttarget, index, err := n.locate(ctx, page, commentID)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\titems, err := page.Elements(`.tabs-content-container > .container`)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"未找到通知条目: %w\", err)\n\t}\n\tif index >= len(items) {\n\t\treturn nil, fmt.Errorf(\"通知条目渲染数(%d)少于目标位置(%d)，页面可能未加载完\", len(items), index)\n\t}\n\titem := items[index]\n\n\thumanize.Delay(ctx, humanize.Reading)\n\n\treplyBtn, err := item.Element(`.action-reply`)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"该通知没有回复入口（评论可能已删除或不可回复）: %w\", err)\n\t}\n\n\thumanize.Delay(ctx, humanize.BeforeClick)\n\tif err := humanize.Click(replyBtn); err != nil {\n\t\treturn nil, fmt.Errorf(\"无法点击回复: %w\", err)\n\t}\n\thumanize.Delay(ctx, humanize.AfterClick)\n\n\tinput, err := item.Element(`textarea.comment-input`)\n\tif err != nil {","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/xiaohongshu/notification_reply.go#L28-L64","documentation":"locate() returns the index of the target comment inside the parsed payload, then Reply indexes into the rendered DOM items. If index >= len(items), the DOM rendered fewer notification entries than expected — usually because the page had not finished loading all items when the elements were queried. This is a consistency guard between API payload and DOM rendering.","triggerScenarios":"Reply called when locate() found the comment at index N (possibly after scroll-loading) but the live DOM only rendered fewer than N+1 `.container` elements at query time.","commonSituations":"Slow network or heavy page left later items unrendered; virtualized list removed earlier items; locate() scrolled fast while DOM lagged behind.","solutions":["Retry the call — the page usually finishes rendering on a second attempt","Slow down network or run on a faster machine/connection","Pre-scroll the notification page before calling Reply","Check if Xiaohongshu introduced virtualized rendering that unloads off-screen items"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"res, err := n.Reply(ctx, commentID, content)\nif err != nil && strings.Contains(err.Error(), \"通知条目渲染数\") {\n    time.Sleep(3 * time.Second)\n    res, err = n.Reply(ctx, commentID, content)\n}","preventionTips":["Retry on slow networks before giving up","Avoid heavy parallel scraping on the same page","Pre-load the notifications page before batch operations"],"tags":["dom","race-condition","rendering","xiaohongshu"],"backgroundTag":"page-not-fully-loaded","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"}