{"record":{"id":"205faa9d4d4d0725","repo":"jackwener/OpenCLI","slug":"key-not-found-in-store-key","errorCode":null,"errorMessage":"Key not found in ${store}: ${key}","messagePattern":"Key not found in (.+?): (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/antigravity/storage.js","lineNumber":133,"sourceCode":"    name: 'storage-get',\n    access: 'read',\n    description: 'Read a single localStorage / sessionStorage value on the Antigravity renderer.',\n    domain: '127.0.0.1',\n    strategy: Strategy.UI,\n    browser: true,\n    args: [\n        { name: 'key', positional: true, required: true, help: 'Storage key name' },\n        { name: 'storage', required: false, default: 'local', help: '\"local\" or \"session\"' },\n        { name: 'max-bytes', type: 'int', required: false, default: 4000, help: 'Truncate value to this many chars' },\n    ],\n    columns: STORAGE_COLUMNS,\n    func: async (page, kwargs) => {\n        const key = String(kwargs?.key || '').trim();\n        if (!key) throw new ArgumentError('key', 'is required');\n        const s = String(kwargs?.storage || 'local').trim().toLowerCase();\n        const store = s === 'session' ? 'sessionStorage' : 'localStorage';\n        const raw = unwrapEvaluateResult(await page.evaluate(`${store}.getItem(${JSON.stringify(key)})`));\n        if (raw === null) throw new CommandExecutionError(`Key not found in ${store}: ${key}`, '');\n        const max = Number.isInteger(kwargs['max-bytes']) && kwargs['max-bytes'] > 0 ? kwargs['max-bytes'] : 4000;\n        let parsed = raw, kind = 'string';\n        try { parsed = JSON.parse(raw); kind = Array.isArray(parsed) ? 'array' : typeof parsed; } catch {}\n        const text = kind === 'string' ? parsed : JSON.stringify(parsed, null, 2);\n        const truncated = text.length > max;\n        return [\n            { Field: 'Key', Value: key },\n            { Field: 'Store', Value: store },\n            { Field: 'Type', Value: kind },\n            { Field: 'Size', Value: `${text.length} chars${truncated ? ' (truncated)' : ''}` },\n            { Field: 'Value', Value: truncated ? text.slice(0, max) + '\\n...(truncated)' : text },\n        ];\n    },\n});\n\n// ====== Renderer-side: cookies ======\ncli({\n    site: 'antigravity',","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/antigravity/storage.js#L115-L151","documentation":"storage-get evaluated `${store}.getItem(key)` on the renderer and got null back, meaning the key does not exist in localStorage or sessionStorage. CommandExecutionError is thrown with the store name and key so the developer knows which store was checked. Note: a key whose stored value is literally the string 'null' or empty string '' is NOT null — only a missing key yields null.","triggerScenarios":"`opencli antigravity storage-get typo.key`, reading a key from 'local' when it lives in 'session' (or vice versa), or querying a key set by a different page/origin than the renderer the CDP session attached to.","commonSituations":"Key names drift between Antigravity versions (prefix changes), keys live under a namespaced prefix (workbench.panel...), or the developer confuses VSCode global state (state.vscdb / state-get) with renderer web storage (storage-get).","solutions":["List actual keys first: `opencli antigravity storage-keys` (optionally --filter substring).","Retry with the other store: add --storage session.","If the data is VSCode state, use `state-get <key>` instead of storage-get.","Check for a vendor prefix on the key name."],"exampleFix":"// before\nopencli antigravity storage-get recentlyOpened\n// after\nopencli antigravity storage-keys --filter recently\nopencli antigravity storage-get workbench.recentlyOpened","handlingStrategy":"try-catch","validationCode":"// Verify the key exists before reading it\nconst out = execSync('opencli antigravity storage-keys', {encoding:'utf8'});\nif (!out.includes('my.key')) throw new Error(`key my.key not in localStorage; run storage-keys to find exact name`);","typeGuard":"function keyExistsInListing(listingOutput, key) {\n  const rows = String(listingOutput).split('\\n').map((l) => l.trim());\n  return rows.some((row) => row.split(/\\s{2,}/).includes(key));\n}","tryCatchPattern":"try {\n  run(`opencli antigravity storage-get ${key}`);\n} catch (e) {\n  if (/Key not found in (localStorage|sessionStorage)/.test(e.message)) {\n    const store = /sessionStorage/.test(e.message) ? 'local' : 'session';\n    run(`opencli antigravity storage-get ${key} --storage ${store}`); // try other store\n  } else throw e;\n}","preventionTips":["Discover exact key names with storage-keys before calling storage-get.","Try both stores (local/session) when unsure where the value lives.","Don't confuse renderer web storage (storage-get) with SQLite state (state-get).","Account for vendor prefixes like workbench.* or vscode.* on key names."],"tags":["key-not-found","storage","lookup-miss","antigravity"],"backgroundTag":"key-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}