{"record":{"id":"7f04cf5f219ec2a0","repo":"xpzouying/xiaohongshu-mcp","slug":"tab-q","errorCode":null,"errorMessage":"未找到子 tab %q","messagePattern":"未找到子 tab %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xiaohongshu/user_profile.go","lineNumber":194,"sourceCode":"\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":176,"sourceCodeEnd":196,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/xiaohongshu/user_profile.go#L176-L196","documentation":"selectTab enumerated all `.reds-tab-item.sub-tab-list` elements and none matched the requested tab label (xiaohongshu/user_profile.go:194). This is a plain (non-wrapped) error with the label in %q, meaning the sub-tab list rendered but the desired tab is absent. Note: elem.Text() errors are silently skipped, so a read failure also surfaces as 'not found'.","triggerScenarios":"Calling GetMyProfileViaSidebar(ctx, tab) with a tab whose label (tabLabel[tab]) doesn't exist on the page — the account has no such sub-tab (e.g. empty 收藏), or the requested ProfileTab value has no mapping in tabLabel so the label is empty and never matches.","commonSituations":"Requesting a tab the account doesn't expose (private likes, empty collections); passing an unsupported/typo ProfileTab value; XHS renaming tab text so the label comparison fails; text read errors being swallowed by `continue`.","solutions":["Verify the ProfileTab value is one the library supports and the target account actually exposes.","Dump the visible sub-tab texts on the page to compare against tabLabel mappings.","Try the default TabNotes to confirm the page itself is fine.","If XHS changed tab wording, update the tabLabel map in the library."],"exampleFix":"// before\nresp, err := action.GetMyProfileViaSidebar(ctx, xiaohongshu.TabLike)\n// after\nif !accountExposesTab(profile, xiaohongshu.TabLike) {\n    resp, err = action.GetMyProfileViaSidebar(ctx, xiaohongshu.TabNotes)\n} else {\n    resp, err = action.GetMyProfileViaSidebar(ctx, xiaohongshu.TabLike)\n}","handlingStrategy":"validation","validationCode":"var tab ProfileTab = tabFlag // validate against supported set first\nswitch tab {\ncase \"\", TabNotes, TabLike, TabCollect:\ndefault:\n    return fmt.Errorf(\"unsupported tab %q\", tab)\n}","typeGuard":null,"tryCatchPattern":"resp, err := action.GetMyProfileViaSidebar(ctx, tab)\nif err != nil && strings.HasPrefix(err.Error(), \"未找到子 tab\") {\n    log.Printf(\"account does not expose tab %s, falling back to notes\", tab)\n    resp, err = action.GetMyProfileViaSidebar(ctx, TabNotes)\n}","preventionTips":["Only request tabs the target account actually exposes.","Use library-defined ProfileTab constants, never free-form strings.","Fall back to the default TabNotes when a tab is absent.","Update tabLabel mappings when XHS renames tab text."],"tags":["browser-automation","dom-selector","tab-not-found","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"}