{"record":{"id":"287995233232cbfa","repo":"xpzouying/xiaohongshu-mcp","slug":"s-w-287995","errorCode":null,"errorMessage":"切换到 %s 失败: %w","messagePattern":"切换到 (.+?) 失败: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xiaohongshu/user_profile.go","lineNumber":188,"sourceCode":"func (u *UserProfileAction) selectTab(ctx context.Context, page *rod.Page, tab ProfileTab) error {\n\tif tab == \"\" || tab == TabNotes {\n\t\treturn nil\n\t}\n\n\tlabel := tabLabel[tab]\n\telems, err := page.Elements(`.reds-tab-item.sub-tab-list`)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"未找到主页子 tab: %w\", err)\n\t}\n\n\tfor _, elem := range elems {\n\t\ttext, err := elem.Text()\n\t\tif err != nil || strings.TrimSpace(text) != label {\n\t\t\tcontinue\n\t\t}\n\t\thumanize.Delay(ctx, humanize.BeforeClick)\n\t\tif err := humanize.Click(elem); err != nil {\n\t\t\treturn fmt.Errorf(\"切换到 %s 失败: %w\", label, err)\n\t\t}\n\t\thumanize.Delay(ctx, humanize.AfterClick)\n\t\tpage.MustWaitStable()\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"未找到子 tab %q\", label)\n}\n","sourceCodeStart":170,"sourceCodeEnd":196,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/xiaohongshu/user_profile.go#L170-L196","documentation":"selectTab found the sub-tab matching the requested label, but humanize.Click on the tab element failed (xiaohongshu/user_profile.go:188). The message names the target tab label (e.g. 喜欢/收藏). The click is wrapped with humanize delays, so failure usually comes from rod's click mechanics (element detached, obscured, or page navigating).","triggerScenarios":"Calling GetMyProfileViaSidebar(ctx, tab) with a non-default tab where the matching `.reds-tab-item` element becomes detached or unclickable between listing and clicking — a re-render replaced the node, an overlay intercepts the click, or the page navigated.","commonSituations":"XHS re-rendered the tab bar right before the click; anti-bot overlay/interstitial on top; slow page causing staleness; browser tab closed by user or timeout.","solutions":["Retry the whole GetMyProfileViaSidebar call; transient re-renders usually succeed on a second pass.","Verify no login wall or verification dialog is blocking the page.","Wait longer after navigation (increase stability wait) before selecting the tab.","If persistent, re-check the tab element selector against current XHS markup."],"exampleFix":"// before\nresp, err := action.GetMyProfileViaSidebar(ctx, tab)\n// after\nvar resp *xiaohongshu.UserProfileResponse\nerr := retry.Do(3, func() error {\n    r, e := action.GetMyProfileViaSidebar(ctx, tab)\n    resp, err = r, e\n    return e\n})","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"var resp *UserProfileResponse\nerr := retry.Do(3, func() error {\n    r, e := action.GetMyProfileViaSidebar(ctx, tab)\n    resp = r\n    return e\n})","preventionTips":["Retry transient click failures — DOM re-renders are usually one-off.","Dismiss any overlay/verification dialogs before clicking.","Allow longer stabilization delay after navigation.","Keep selectors current with XHS markup changes."],"tags":["browser-automation","click-failed","go-rod","xiaohongshu"],"backgroundTag":"element-click-failed","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"}