jackwener/OpenCLI · error · CommandExecutionError

Key not found: ${key}

Error message

Key not found: ${key}

What it means

state-get queried the resolved state.vscdb's ItemTable for the given key; getValue() returned null (empty query result), meaning no row with that exact key exists in the global or workspace DB. A CommandExecutionError names the missing key. Keys must match byte-for-byte — no prefix or fuzzy matching is performed.

Source

Thrown at clis/antigravity/storage.js:239

    site: 'antigravity',
    name: 'state-get',
    access: 'read',
    description: 'Read one value from Antigravity\'s state.vscdb. Pass --workspace <id> for per-workspace.',
    domain: 'localhost',
    strategy: Strategy.LOCAL,
    browser: false,
    args: [
        { name: 'key', positional: true, required: true, help: 'Storage key name' },
        { name: 'workspace', required: false, help: 'Workspace id (from workspaces-list) to query per-workspace DB' },
        { name: 'max-bytes', type: 'int', required: false, default: 8000, help: 'Truncate value to this many chars' },
    ],
    columns: STORAGE_COLUMNS,
    func: async (args) => {
        const key = String(args?.key || '').trim();
        if (!key) throw new ArgumentError('key', 'is required');
        const db = resolveStateDb(args);
        const val = getValue(db, key);
        if (val === null) throw new CommandExecutionError(`Key not found: ${key}`, '');
        const max = Number.isInteger(args['max-bytes']) && args['max-bytes'] > 0 ? args['max-bytes'] : 8000;
        const valStr = typeof val === 'string' ? val : JSON.stringify(val, null, 2);
        const truncated = valStr.length > max;
        return [
            { Field: 'Key', Value: key },
            { Field: 'Type', Value: typeof val === 'string' ? 'string' : (Array.isArray(val) ? 'array' : typeof val) },
            { Field: 'Size', Value: `${valStr.length} chars${truncated ? ' (truncated)' : ''}` },
            { Field: 'Value', Value: truncated ? valStr.slice(0, max) + '\n...(truncated)' : valStr },
        ];
    },
});

// ====== FS-side: recent-paths ======
cli({
    site: 'antigravity',
    name: 'recent-paths',
    access: 'read',
    description: 'Show Antigravity\'s recently-opened folders/files (history.recentlyOpenedPathsList).',

View on GitHub (pinned to 49907e53dc)

Solutions

  1. List exact keys first: `opencli antigravity state-keys` (optionally --filter substring).
  2. Copy the key verbatim from state-keys output — matching is exact.
  3. Retry with/without --workspace to check the other database.
  4. If the value is a user setting, use `opencli antigravity settings-read` instead.

Example fix

// before
opencli antigravity state-get recentlyOpenedPathsList
// after
opencli antigravity state-keys --filter recently
opencli antigravity state-get history.recentlyOpenedPathsList
Defensive patterns

Strategy: try-catch

Validate before calling

// Verify the exact key exists in the target DB before reading
const out = execSync('opencli antigravity state-keys' + (ws ? ` --workspace ${ws}` : ''), {encoding:'utf8'});
if (!out.includes('history.recentlyOpenedPathsList')) throw new Error('key not present in this DB; check state-keys output for exact name');

Type guard

function keyInListing(listingOutput, key) {
  return String(listingOutput).split('\n').some((row) => row.split(/\s{2,}/).includes(key));
}

Try / catch

try {
  run(`opencli antigravity state-get ${key}`);
} catch (e) {
  if (/^Key not found: /.test(e.message)) {
    run(`opencli antigravity state-get ${key} --workspace ${ws}`); // try workspace DB
  } else throw e;
}

Prevention

When it happens

Trigger: `opencli antigravity state-get wrongKey`, reading a key that only exists in the workspace DB while running against the global DB (or vice versa), or key names that changed across Antigravity versions.

Common situations: Confusing settings.json keys (file-based) with ItemTable keys (SQLite), missing the extension/vendor prefix on the key, or querying a per-workspace DB via --workspace when the record lives globally.

Related errors


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