{"record":{"id":"84e01e81ad85c74d","repo":"xpzouying/xiaohongshu-mcp","slug":"d-d","errorCode":null,"errorMessage":"通知条目渲染数(%d)少于目标位置(%d)，页面可能未加载完","messagePattern":"通知条目渲染数\\((.+?)\\)少于目标位置\\((.+?)\\)，页面可能未加载完","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xiaohongshu/notification_like.go","lineNumber":60,"sourceCode":"\n\tresult := &NotificationLikeResult{\n\t\tCommentID: commentID,\n\t\tNickname:  target.from().Nickname,\n\t\tLiked:     want,\n\t}\n\n\tif target.Comment.Liked == want {\n\t\tresult.Skipped = true\n\t\tlogrus.Infof(\"通知点赞跳过（已是目标状态）: comment=%s liked=%v\", commentID, want)\n\t\treturn result, nil\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\n\thumanize.Delay(ctx, humanize.Reading)\n\n\tbtn, err := items[index].Element(`.action-like .like-wrapper`)\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(btn); err != nil {\n\t\treturn nil, fmt.Errorf(\"无法点击点赞: %w\", err)\n\t}\n\n\tif err := n.waitLikeSettled(page, commentID, want); err != nil {\n\t\treturn nil, err\n\t}\n","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/xiaohongshu/notification_like.go#L42-L78","documentation":"Like 已知目标通知在数据列表中的位置 index，但渲染出的 .container 条目数量不大于 index：页面还没渲染完足够的条目（懒加载/渲染延迟），定位不到要点击的那条通知。","triggerScenarios":"Like 内部 locate 得到的 index >= len(items)：目标评论在通知列表较深位置但页面只渲染了第一屏；通知已被刷出列表；分页/懒加载未触发。","commonSituations":"目标评论的通知太久远被更新的通知挤掉；通知列表很短而 index 由历史数据计算；页面懒加载没滚到底。","solutions":["先用 list_notifications 刷新通知列表，确认目标 commentID 仍在列表内","在页面内滚动触发懒加载后再获取元素","若通知已不在列表，走备选路径（直接通过评论接口操作）","重试一次，因为列表顺序是动态变化的"],"exampleFix":"// before\nif index >= len(items) { return nil, fmt.Errorf(\"通知条目渲染数(%d)少于目标位置(%d)...\", len(items), index) }\n// after\nfor index >= len(items) && attempts < 3 {\n    humanize.ScrollDown(page)\n    items, err = page.Elements(`.tabs-content-container > .container`)\n    attempts++\n}\nif index >= len(items) { return nil, fmt.Errorf(\"通知条目渲染数(%d)少于目标位置(%d)...\", len(items), index) }","handlingStrategy":"retry","validationCode":"// 先确认目标通知仍在列表前几屏\nitems, _ := n.List(ctx)\nfound := false\nfor _, it := range items { if it.CommentID == commentID { found = true; break } }\nif !found { return errors.New(\"notification not in first page\") }","typeGuard":null,"tryCatchPattern":"_, err := n.Like(ctx, commentID, false)\nif err != nil && strings.Contains(err.Error(), \"少于目标位置\") {\n    // 刷新列表后重试；仍失败则改走直接评论接口\n    _, err = n.Like(ctx, commentID, false)\n}","preventionTips":["操作前先 list_notifications 确认目标还在列表中","优先处理近期通知，避免目标被挤到深处","在页面内滚动触发懒加载后再定位","对动态列表做好重试与降级路径"],"tags":["go","rod","lazy-loading","dom-selector"],"backgroundTag":"dom-element-not-found","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"}