jackwener/OpenCLI · warning · EmptyResultError

document.cookie is empty (likely all cookies are httpOnly).

Error message

document.cookie is empty (likely all cookies are httpOnly).

What it means

EmptyResultError thrown by kimi cookies when document.cookie evaluates to an empty string on the Kimi page. Non-httpOnly cookies are the only ones visible to document.cookie, so an empty result usually means every cookie is marked httpOnly (invisible to JS) or no cookies exist on this origin.

Source

Thrown at clis/kimi/storage.js:129

// -------- cookies --------
cli({
    site: 'kimi',
    name: 'cookies',
    access: 'read',
    description: 'List kimi.com cookies visible to JavaScript (httpOnly cookies are deliberately not shown).',
    domain: KIMI_DOMAIN,
    strategy: Strategy.COOKIE,
    browser: true,
    siteSession: 'persistent',
    navigateBefore: false,
    args: [],
    columns: STORAGE_COLUMNS,
    func: async (page) => {
        await ensureOnKimi(page);
        const raw = await page.evaluate('document.cookie');
        if (!raw) {
            throw new EmptyResultError('kimi cookies', 'document.cookie is empty (likely all cookies are httpOnly).');
        }
        const cookies = raw.split('; ').map((pair) => {
            const idx = pair.indexOf('=');
            if (idx < 0) return { name: pair, value: '' };
            return { name: pair.slice(0, idx), value: pair.slice(idx + 1) };
        });
        return cookies.map((c, i) => ({
            Index: i + 1,
            Name: c.name,
            Bytes: c.value.length,
            Preview: c.value.slice(0, 40) + (c.value.length > 40 ? '…' : ''),
        }));
    },
});

// -------- idb-list --------
cli({
    site: 'kimi',

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Use the browser/automation layer's cookie API instead of document.cookie for httpOnly cookies (e.g. page.cookies() / CDP Network.getAllCookies)
  2. Verify in DevTools (Application > Cookies) which cookies exist and whether they are httpOnly
  3. Check you are on the correct domain; cookies are origin-scoped
  4. If JS-visible cookies are expected, confirm login happened so cookies were actually set

Example fix

// before
const cookies = await kimi(['storage', 'cookies']); // fails if all httpOnly
// after
// read cookies via the automation API instead:
const all = await page.evaluate('document.cookie')
  ? await kimi(['storage', 'cookies'])
  : await browser.cookies.getAll({ domain: 'kimi.com' }); // includes httpOnly
Defensive patterns

Strategy: fallback

Validate before calling

const jsCookies = await page.evaluate('document.cookie');
if (!jsCookies) console.warn('no JS-visible cookies; use CDP/browser cookie API');

Type guard

const hasCookies = (raw) => typeof raw === 'string' && raw.trim().length > 0;

Try / catch

try {
  return await kimi(['storage', 'cookies']);
} catch (e) {
  if (/document.cookie is empty/.test(e.message)) {
    // fall back to automation-layer cookie API which sees httpOnly cookies
    return await browser.cookies.getAll({ domain: 'kimi.com' });
  }
  throw e;
}

Prevention

When it happens

Trigger: Running `kimi storage cookies` on kimi.com where all session/auth cookies are Set-Cookie with HttpOnly, before any cookie is set, or after the site cleared them.

Common situations: Trying to inspect auth tokens that are deliberately httpOnly (this command can never see them), running against a fresh profile with no cookies, or on a domain/path where no JS-visible cookies are scoped.

Related errors


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