{"record":{"id":"a372ded553e4ddc6","repo":"jackwener/OpenCLI","slug":"taobao-search-requires-a-logged-in-taobao-session","errorCode":null,"errorMessage":"taobao search requires a logged-in Taobao session","messagePattern":"taobao search requires a logged-in Taobao session","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"clis/taobao/search.js","lineNumber":93,"sourceCode":"\n          results.push({\n            rank: results.length + 1,\n            title: title.slice(0, 80),\n            price,\n            sales,\n            shop,\n            location,\n            item_id: itemId,\n            url: itemId ? 'https://item.taobao.com/item.htm?id=' + itemId : '',\n          });\n          if (results.length >= ${limit}) break;\n        }\n\n        return { results };\n      })()\n    `);\n        if (data?.error === 'auth-required') {\n            throw new AuthRequiredError('taobao search requires a logged-in Taobao session');\n        }\n        return Array.isArray(data?.results) ? data.results : [];\n    },\n});\n","sourceCodeStart":75,"sourceCodeEnd":98,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/taobao/search.js#L75-L98","documentation":"The taobao search command's in-page script reports { error: 'auth-required' } when Taobao serves a login wall instead of search results; the wrapper raises AuthRequiredError. Taobao requires a logged-in session for search, so the library surfaces this instead of returning empty results.","triggerScenarios":"Invoking taobao search when the rendered page contains the auth-required marker — typically Taobao redirected the search URL to login.taobao.com or injected a login modal because the session cookie is absent/expired.","commonSituations":"Search before any login; expired session cookies; search rate-limited into forced re-login; fresh browser profile without restored cookies.","solutions":["Authenticate via the taobao login flow, then retry the search","Load a persisted, valid cookie state before searching","Wrap search calls to catch AuthRequiredError and trigger login+retry","Throttle search frequency to avoid anti-bot forced login"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (!(await hasTaobaoSessionCookie(page))) {\n  throw new Error('Login to Taobao before searching');\n}","typeGuard":"function isAuthRequiredError(e) {\n  return e instanceof AuthRequiredError || /logged-in Taobao session/.test(String(e?.message));\n}","tryCatchPattern":"try {\n  const results = await taobaoSearch(page, { keyword, limit });\n} catch (e) {\n  if (isAuthRequiredError(e)) {\n    await taobaoLogin(page);\n    return taobaoSearch(page, { keyword, limit });\n  }\n  throw e;\n}","preventionTips":["Authenticate before any search; Taobao search is login-gated","Throttle requests to avoid anti-bot forced re-login","Detect login.taobao.com redirects early and re-authenticate","Reuse one logged-in browser context across search calls"],"tags":["auth","taobao","search","scraping"],"backgroundTag":"auth-required-for-scrape","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}