{"record":{"id":"a88cb7ff918a6023","repo":"xpzouying/xiaohongshu-mcp","slug":"feed-s-s","errorCode":null,"errorMessage":"feed %s %s失败：点击后状态始终未变为预期","messagePattern":"feed (.+?) (.+?)失败：点击后状态始终未变为预期","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xiaohongshu/like_favorite.go","lineNumber":88,"sourceCode":"// 到达即成功；始终未变或无法读状态则返回 error——消除\"点了没报错就算成功\"的假阳性。\nfunc (a *interactAction) toggleInteract(ctx context.Context, page *rod.Page, feedID, selector string, want bool, actionType interactActionType, pick stateOf) error {\n\tfor attempt := 1; attempt <= 2; attempt++ {\n\t\tif err := a.performClick(page, selector); err != nil {\n\t\t\treturn fmt.Errorf(\"%s点击失败: %w\", actionType, err)\n\t\t}\n\n\t\tok, err := a.waitInteractState(page, feedID, want, pick, 4*time.Second)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"%s后无法确认状态: %w\", actionType, err)\n\t\t}\n\t\tif ok {\n\t\t\thumanize.Delay(ctx, humanize.AfterInteract)\n\t\t\tlogrus.Infof(\"feed %s %s成功（第%d次点击）\", feedID, actionType, attempt)\n\t\t\treturn nil\n\t\t}\n\t\tlogrus.Warnf(\"feed %s %s第%d次点击后状态未变，重试\", feedID, actionType, attempt)\n\t}\n\treturn fmt.Errorf(\"feed %s %s失败：点击后状态始终未变为预期\", feedID, actionType)\n}\n\n// waitInteractState 轮询 __INITIAL_STATE__ 的交互状态，直到 pick()==want 或超时。\n// 状态回写快则立即返回、慢则等满 timeout。\nfunc (a *interactAction) waitInteractState(page *rod.Page, feedID string, want bool, pick stateOf, timeout time.Duration) (bool, error) {\n\tdeadline := time.Now().Add(timeout)\n\tfor {\n\t\tliked, collected, err := a.getInteractState(page, feedID)\n\t\tif err != nil {\n\t\t\treturn false, err\n\t\t}\n\t\tif pick(liked, collected) == want {\n\t\t\treturn true, nil\n\t\t}\n\t\tif time.Now().After(deadline) {\n\t\t\treturn false, nil\n\t\t}\n\t\ttime.Sleep(500 * time.Millisecond)","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/xiaohongshu/like_favorite.go#L70-L106","documentation":"toggleInteract 点击点赞/收藏后 4 秒内轮询 __INITIAL_STATE__ 状态始终未变成预期值（两次尝试均未确认）：点击可能落空、状态同步延迟，或账号被限制互动。设计上宁可报错也不假阳性。","triggerScenarios":"Thrown at xiaohongshu/like_favorite.go:88 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["读取当前点赞/收藏状态确认是否实际生效","若未生效则稍后重试一次","检查账号是否被限流"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}