jackwener/OpenCLI · error · AuthRequiredError

taobao search requires a logged-in Taobao session

Error message

taobao search requires a logged-in Taobao session

What it means

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.

Source

Thrown at clis/taobao/search.js:93

          results.push({
            rank: results.length + 1,
            title: title.slice(0, 80),
            price,
            sales,
            shop,
            location,
            item_id: itemId,
            url: itemId ? 'https://item.taobao.com/item.htm?id=' + itemId : '',
          });
          if (results.length >= ${limit}) break;
        }

        return { results };
      })()
    `);
        if (data?.error === 'auth-required') {
            throw new AuthRequiredError('taobao search requires a logged-in Taobao session');
        }
        return Array.isArray(data?.results) ? data.results : [];
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Authenticate via the taobao login flow, then retry the search
  2. Load a persisted, valid cookie state before searching
  3. Wrap search calls to catch AuthRequiredError and trigger login+retry
  4. Throttle search frequency to avoid anti-bot forced login
Defensive patterns

Strategy: try-catch

Validate before calling

if (!(await hasTaobaoSessionCookie(page))) {
  throw new Error('Login to Taobao before searching');
}

Type guard

function isAuthRequiredError(e) {
  return e instanceof AuthRequiredError || /logged-in Taobao session/.test(String(e?.message));
}

Try / catch

try {
  const results = await taobaoSearch(page, { keyword, limit });
} catch (e) {
  if (isAuthRequiredError(e)) {
    await taobaoLogin(page);
    return taobaoSearch(page, { keyword, limit });
  }
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: Search before any login; expired session cookies; search rate-limited into forced re-login; fresh browser profile without restored cookies.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/a372ded553e4ddc6. Report an issue: GitHub.