{"record":{"id":"b0fa82ef7bcb011f","repo":"xpzouying/xiaohongshu-mcp","slug":"s-v-list-notifica","errorCode":null,"errorMessage":"点赞未确认成功：%s 内状态未变成 %v。点赞可能已生效但同步慢，请先用 list_notifications 读一次当前状态再决定是否重试","messagePattern":"点赞未确认成功：(.+?) 内状态未变成 (.+?)。点赞可能已生效但同步慢，请先用 list_notifications 读一次当前状态再决定是否重试","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"xiaohongshu/notification_like.go","lineNumber":90,"sourceCode":"\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\n\thumanize.Delay(ctx, humanize.AfterInteract)\n\n\tlogrus.Infof(\"通知点赞成功: comment=%s liked=%v\", commentID, want)\n\treturn result, nil\n}\n\n// waitLikeSettled 等待点赞状态变成目标值；判不出来直接报错，不自动重试。\nfunc (n *NotificationAction) waitLikeSettled(page *rod.Page, commentID string, want bool) error {\n\tif n.likedMatches(page, commentID, want, likeSettleTimeout) {\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"点赞未确认成功：%s 内状态未变成 %v。点赞可能已生效但同步慢，\"+\n\t\t\"请先用 list_notifications 读一次当前状态再决定是否重试\", likeSettleTimeout, want)\n}\n\n// likedMatches 轮询状态，直到目标评论的 liked 等于 want 或超时。\nfunc (n *NotificationAction) likedMatches(page *rod.Page, commentID string, want bool, timeout time.Duration) bool {\n\tdeadline := time.Now().Add(timeout)\n\tfor time.Now().Before(deadline) {\n\t\tpayload, err := n.readTab(page, TabMentions)\n\t\tif err == nil {\n\t\t\tfor _, r := range payload.MessageList {\n\t\t\t\tif r.Comment.ID == commentID {\n\t\t\t\t\tif r.Comment.Liked == want {\n\t\t\t\t\t\treturn true\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/xiaohongshu/notification_like.go#L72-L108","documentation":"waitLikeSettled 在 likeSettleTimeout（15s）内轮询通知数据中该评论的 liked 状态始终未变成目标值。因为无法区分「点赞实际已生效但同步慢」与「根本没点上」，所以提示先读一次当前状态再决定是否重试，避免重复点赞。","triggerScenarios":"Like 点击后调用 waitLikeSettled 超时：服务端同步延迟、点击实际未生效（被风控拦截）、页面状态未刷新导致 likedMatches 读到旧值。","commonSituations":"小红书点赞接口延迟高；高频自动化操作触发风控静默失败；页面状态缓存导致轮询一直读旧数据。","solutions":["按错误提示先调用 list_notifications 读取当前 liked 状态再决定是否重试","延长 settle 超时（如通过更长的等待窗口）后重试一次","若多次未确认成功，停止重试，人工检查是否触发风控","在页面上刷新或重新导航后再次轮询状态"],"exampleFix":"// before\nif err := n.waitLikeSettled(page, commentID, want); err != nil { return nil, err }\n// after\nif err := n.waitLikeSettled(page, commentID, want); err != nil {\n    result, listErr := n.List(ctx, \"like\")\n    if listErr == nil && notificationHasLiked(result, commentID, want) {\n        return likeResult, nil // 实际已生效\n    }\n    return nil, err\n}","handlingStrategy":"validation","validationCode":"// 超时后先读当前状态再决定是否重试\nitems, err := n.List(ctx)\nif err != nil { return err }\nfor _, it := range items {\n    if it.CommentID == commentID && it.Liked == want { return nil /* 已生效，勿重试 */ }\n}","typeGuard":null,"tryCatchPattern":"_, err := n.Like(ctx, commentID, false)\nif err != nil && strings.Contains(err.Error(), \"点赞未确认成功\") {\n    if !currentStateMatches(ctx, n, commentID, want) {\n        time.Sleep(5 * time.Second)\n        _, err = n.Like(ctx, commentID, want) // 确认未生效才重试\n    }\n}","preventionTips":["重试前必须先读当前 liked 状态，避免重复点赞","控制操作频率，避免触发风控静默失败","接受点赞可能延迟生效，超时不宜过短","建立人工复核通道处理多次未确认的情况"],"tags":["go","rod","timeout","sync-delay","like-confirmation"],"backgroundTag":"operation-not-confirmed-timeout","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"}