jackwener/OpenCLI · error · AuthRequiredError
JD pin cookie empty after decode (probe.detail)
Error message
JD pin cookie empty after decode (probe.detail)
What it means
verifyJdIdentity throws AuthRequiredError('jd.com', probe.detail) when the in-page probe reports kind='auth' with detail 'JD pin cookie empty after decode (probe.detail)' — the 'pin' cookie exists but its decoded value is empty/invalid, so the session is unusable even though a cookie is present.
Source
Thrown at clis/jd/auth.js:28
async function verifyJdIdentity(page) {
if (!await hasJdSessionCookie(page)) {
throw new AuthRequiredError('jd.com', 'JD pin / thor cookie missing');
}
await page.goto('https://home.jd.com/');
await page.wait(3);
const probe = await page.evaluate(`
(() => {
const pinCookie = (document.cookie.split('; ').find(c => c.startsWith('pin=')) || '').split('=')[1] || '';
const decoded = pinCookie ? decodeURIComponent(pinCookie) : '';
if (!decoded) {
return { kind: 'auth', detail: 'JD pin cookie empty after decode' };
}
const nickEl = document.querySelector('.user-info, #aliveUserName, .name, .user-name');
const nickname = (nickEl && nickEl.textContent && nickEl.textContent.trim()) || '';
return { ok: true, pin: decoded, nickname };
})()
`);
if (probe?.kind === 'auth') throw new AuthRequiredError('jd.com', probe.detail);
if (!probe?.ok) throw new CommandExecutionError(`Unexpected JD probe: ${JSON.stringify(probe)}`);
return { pin: probe.pin, nickname: probe.nickname };
}
registerSiteAuthCommands({
site: 'jd',
domain: 'jd.com',
loginUrl: 'https://passport.jd.com/new/login.aspx',
columns: ['pin', 'nickname'],
quickCheck: hasJdSessionCookie,
verify: verifyJdIdentity,
poll: async (page) => {
if (!await hasJdSessionCookie(page)) {
throw new AuthRequiredError('jd.com', 'Waiting for JD pin / thor cookie');
}
return verifyJdIdentity(page);
},
});View on GitHub (pinned to 49907e53dc)
Solutions
- Delete the stale JD cookies (pin/thor) in the browser profile and log in again at https://www.jd.com
- Run `jd auth login` to establish a fresh session
- Re-run the verify command after re-login
Example fix
// before
await jdWhoami(); // fails with empty pin cookie
// after
await clearCookies({ domain: '.jd.com' });
await jdAuthLogin();
const me = await jdWhoami(); Defensive patterns
Strategy: try-catch
Validate before calling
const pin = (await page.getCookies({ url: 'https://www.jd.com' }))
.find(c => c.name === 'pin');
if (!pin || !pin.value || !decodeURIComponent(pin.value)) {
await clearCookies({ domain: '.jd.com' });
await jdAuthLogin();
} Type guard
function hasValidPin(cookies) {
const pin = cookies.find(c => c.name === 'pin');
return !!pin && !!pin.value && !!decodeURIComponent(pin.value);
} Try / catch
try {
await jdVerify();
} catch (e) {
if (e.code === 'AUTH_REQUIRED' && /empty after decode/.test(e.detail || e.message)) {
await clearCookies({ domain: '.jd.com' });
await jdAuthLogin();
} else throw e;
} Prevention
- Re-login rather than trusting a present-but-empty pin cookie
- Clear JD cookies on AUTH_REQUIRED before retrying login
- Periodically refresh JD sessions in long-running automation
- Log out/in cleanly instead of keeping half-expired cookies
When it happens
Trigger: The JD 'pin' cookie is present but empty after decodeURIComponent, typically a stale or cleared-value cookie left behind after logout or partial session expiry; detected inside the page.evaluate probe on home.jd.com.
Common situations: Half-expired JD session: cookie exists but server invalidated it; cookie set with empty value by JD on logout; corrupted cookie from an old login.
Related errors
- jd.com
- Xiaoe admin page rendered but no user_id cookie extractable
- 1point3acres Discuz *_auth cookie missing
- Waiting for Bilibili session cookies
- Bilibili ${label} API requires login or permission: ${messag
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/f629fa01756c10cf.
Report an issue: GitHub.