{"record":{"id":"b090deeb23ac0b08","repo":"xpzouying/xiaohongshu-mcp","slug":"tab-w","errorCode":null,"errorMessage":"未找到主页子 tab: %w","messagePattern":"未找到主页子 tab: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xiaohongshu/user_profile.go","lineNumber":178,"sourceCode":"\tpage.MustWaitStable()\n\n\tif err := u.selectTab(ctx, page, tab); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn u.extractUserProfileData(page, tab)\n}\n\n// selectTab 切到目标子 tab。「笔记」是默认 tab，无需点击。\nfunc (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":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/xiaohongshu/user_profile.go#L160-L196","documentation":"selectTab fails while querying the profile page's sub-tab elements via the CSS selector `.reds-tab-item.sub-tab-list` (xiaohongshu/user_profile.go:178). This error means the rod call to enumerate sub-tab elements itself errored (element lookup/eval failure), not that matching tabs are absent. GetMyProfileViaSidebar propagates it unchanged.","triggerScenarios":"Calling GetMyProfileViaSidebar with a non-default tab (e.g. TabCollect/TabLike) when page.Elements(`.reds-tab-item.sub-tab-list`) returns a rod error — page navigated away, JS context destroyed, or page closed.","commonSituations":"Profile page redirected to a login wall so the sub-tab bar never rendered; page crashed mid-navigation; browser disconnected.","solutions":["Check the wrapped rod error — if it indicates no element, the page likely never rendered the tab bar; verify login state.","Re-navigate and retry after MustWaitStable.","If XHS renamed the sub-tab classes, update the `.reds-tab-item.sub-tab-list` selector."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"resp, err := action.GetMyProfileViaSidebar(ctx, tab)\nif err != nil && strings.Contains(err.Error(), \"未找到主页子 tab\") {\n    // page never rendered the tab bar — re-navigate or check login\n    return reLoginAndRetry(ctx)\n}","preventionTips":["Verify login state first; a login wall hides the sub-tab bar.","Wait for page stability before tab operations.","Handle page-closed/crashed rod errors by recreating the page."],"tags":["browser-automation","dom-selector","go-rod","xiaohongshu"],"backgroundTag":"element-not-found","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"}