jackwener/OpenCLI · error · CommandExecutionError

Key not found in ${store}: ${key}

Error message

Key not found in ${store}: ${key}

What it means

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.

Source

Thrown at clis/antigravity/storage.js:133

    name: 'storage-get',
    access: 'read',
    description: 'Read a single localStorage / sessionStorage value on the Antigravity renderer.',
    domain: '127.0.0.1',
    strategy: Strategy.UI,
    browser: true,
    args: [
        { name: 'key', positional: true, required: true, help: 'Storage key name' },
        { name: 'storage', required: false, default: 'local', help: '"local" or "session"' },
        { name: 'max-bytes', type: 'int', required: false, default: 4000, help: 'Truncate value to this many chars' },
    ],
    columns: STORAGE_COLUMNS,
    func: async (page, kwargs) => {
        const key = String(kwargs?.key || '').trim();
        if (!key) throw new ArgumentError('key', 'is required');
        const s = String(kwargs?.storage || 'local').trim().toLowerCase();
        const store = s === 'session' ? 'sessionStorage' : 'localStorage';
        const raw = unwrapEvaluateResult(await page.evaluate(`${store}.getItem(${JSON.stringify(key)})`));
        if (raw === null) throw new CommandExecutionError(`Key not found in ${store}: ${key}`, '');
        const max = Number.isInteger(kwargs['max-bytes']) && kwargs['max-bytes'] > 0 ? kwargs['max-bytes'] : 4000;
        let parsed = raw, kind = 'string';
        try { parsed = JSON.parse(raw); kind = Array.isArray(parsed) ? 'array' : typeof parsed; } catch {}
        const text = kind === 'string' ? parsed : JSON.stringify(parsed, null, 2);
        const truncated = text.length > max;
        return [
            { Field: 'Key', Value: key },
            { Field: 'Store', Value: store },
            { Field: 'Type', Value: kind },
            { Field: 'Size', Value: `${text.length} chars${truncated ? ' (truncated)' : ''}` },
            { Field: 'Value', Value: truncated ? text.slice(0, max) + '\n...(truncated)' : text },
        ];
    },
});

// ====== Renderer-side: cookies ======
cli({
    site: 'antigravity',

View on GitHub (pinned to 49907e53dc)

Solutions

  1. List actual keys first: `opencli antigravity storage-keys` (optionally --filter substring).
  2. Retry with the other store: add --storage session.
  3. If the data is VSCode state, use `state-get <key>` instead of storage-get.
  4. Check for a vendor prefix on the key name.

Example fix

// before
opencli antigravity storage-get recentlyOpened
// after
opencli antigravity storage-keys --filter recently
opencli antigravity storage-get workbench.recentlyOpened
Defensive patterns

Strategy: try-catch

Validate before calling

// Verify the key exists before reading it
const out = execSync('opencli antigravity storage-keys', {encoding:'utf8'});
if (!out.includes('my.key')) throw new Error(`key my.key not in localStorage; run storage-keys to find exact name`);

Type guard

function keyExistsInListing(listingOutput, key) {
  const rows = String(listingOutput).split('\n').map((l) => l.trim());
  return rows.some((row) => row.split(/\s{2,}/).includes(key));
}

Try / catch

try {
  run(`opencli antigravity storage-get ${key}`);
} catch (e) {
  if (/Key not found in (localStorage|sessionStorage)/.test(e.message)) {
    const store = /sessionStorage/.test(e.message) ? 'local' : 'session';
    run(`opencli antigravity storage-get ${key} --storage ${store}`); // try other store
  } else throw e;
}

Prevention

When it happens

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

Common situations: 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).

Related errors


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