{"record":{"id":"5c5002b49195f275","repo":"jackwener/OpenCLI","slug":"document-cookie-is-empty-likely-all-cookies-are-h","errorCode":null,"errorMessage":"document.cookie is empty (likely all cookies are httpOnly).","messagePattern":"document\\.cookie is empty \\(likely all cookies are httpOnly\\)\\.","errorType":"exception","errorClass":"EmptyResultError","httpStatus":null,"severity":"warning","filePath":"clis/kimi/storage.js","lineNumber":129,"sourceCode":"\n// -------- cookies --------\ncli({\n    site: 'kimi',\n    name: 'cookies',\n    access: 'read',\n    description: 'List kimi.com cookies visible to JavaScript (httpOnly cookies are deliberately not shown).',\n    domain: KIMI_DOMAIN,\n    strategy: Strategy.COOKIE,\n    browser: true,\n    siteSession: 'persistent',\n    navigateBefore: false,\n    args: [],\n    columns: STORAGE_COLUMNS,\n    func: async (page) => {\n        await ensureOnKimi(page);\n        const raw = await page.evaluate('document.cookie');\n        if (!raw) {\n            throw new EmptyResultError('kimi cookies', 'document.cookie is empty (likely all cookies are httpOnly).');\n        }\n        const cookies = raw.split('; ').map((pair) => {\n            const idx = pair.indexOf('=');\n            if (idx < 0) return { name: pair, value: '' };\n            return { name: pair.slice(0, idx), value: pair.slice(idx + 1) };\n        });\n        return cookies.map((c, i) => ({\n            Index: i + 1,\n            Name: c.name,\n            Bytes: c.value.length,\n            Preview: c.value.slice(0, 40) + (c.value.length > 40 ? '…' : ''),\n        }));\n    },\n});\n\n// -------- idb-list --------\ncli({\n    site: 'kimi',","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/kimi/storage.js#L111-L147","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Use the browser/automation layer's cookie API instead of document.cookie for httpOnly cookies (e.g. page.cookies() / CDP Network.getAllCookies)","Verify in DevTools (Application > Cookies) which cookies exist and whether they are httpOnly","Check you are on the correct domain; cookies are origin-scoped","If JS-visible cookies are expected, confirm login happened so cookies were actually set"],"exampleFix":"// before\nconst cookies = await kimi(['storage', 'cookies']); // fails if all httpOnly\n// after\n// read cookies via the automation API instead:\nconst all = await page.evaluate('document.cookie')\n  ? await kimi(['storage', 'cookies'])\n  : await browser.cookies.getAll({ domain: 'kimi.com' }); // includes httpOnly","handlingStrategy":"fallback","validationCode":"const jsCookies = await page.evaluate('document.cookie');\nif (!jsCookies) console.warn('no JS-visible cookies; use CDP/browser cookie API');","typeGuard":"const hasCookies = (raw) => typeof raw === 'string' && raw.trim().length > 0;","tryCatchPattern":"try {\n  return await kimi(['storage', 'cookies']);\n} catch (e) {\n  if (/document.cookie is empty/.test(e.message)) {\n    // fall back to automation-layer cookie API which sees httpOnly cookies\n    return await browser.cookies.getAll({ domain: 'kimi.com' });\n  }\n  throw e;\n}","preventionTips":["Use the browser/CDP cookie API for httpOnly cookies","Verify in DevTools which cookies exist before automating","Check the current origin matches where cookies were set","Ensure login completed so cookies were actually issued"],"tags":["cookies","httponly","empty-result","kimi"],"backgroundTag":"empty-cookie-jar","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}