{"record":{"id":"d861681f93dd16d9","repo":"jackwener/OpenCLI","slug":"key-not-found-key","errorCode":null,"errorMessage":"Key not found: ${key}","messagePattern":"Key not found: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/antigravity/storage.js","lineNumber":239,"sourceCode":"    site: 'antigravity',\n    name: 'state-get',\n    access: 'read',\n    description: 'Read one value from Antigravity\\'s state.vscdb. Pass --workspace <id> for per-workspace.',\n    domain: 'localhost',\n    strategy: Strategy.LOCAL,\n    browser: false,\n    args: [\n        { name: 'key', positional: true, required: true, help: 'Storage key name' },\n        { name: 'workspace', required: false, help: 'Workspace id (from workspaces-list) to query per-workspace DB' },\n        { name: 'max-bytes', type: 'int', required: false, default: 8000, help: 'Truncate value to this many chars' },\n    ],\n    columns: STORAGE_COLUMNS,\n    func: async (args) => {\n        const key = String(args?.key || '').trim();\n        if (!key) throw new ArgumentError('key', 'is required');\n        const db = resolveStateDb(args);\n        const val = getValue(db, key);\n        if (val === null) throw new CommandExecutionError(`Key not found: ${key}`, '');\n        const max = Number.isInteger(args['max-bytes']) && args['max-bytes'] > 0 ? args['max-bytes'] : 8000;\n        const valStr = typeof val === 'string' ? val : JSON.stringify(val, null, 2);\n        const truncated = valStr.length > max;\n        return [\n            { Field: 'Key', Value: key },\n            { Field: 'Type', Value: typeof val === 'string' ? 'string' : (Array.isArray(val) ? 'array' : typeof val) },\n            { Field: 'Size', Value: `${valStr.length} chars${truncated ? ' (truncated)' : ''}` },\n            { Field: 'Value', Value: truncated ? valStr.slice(0, max) + '\\n...(truncated)' : valStr },\n        ];\n    },\n});\n\n// ====== FS-side: recent-paths ======\ncli({\n    site: 'antigravity',\n    name: 'recent-paths',\n    access: 'read',\n    description: 'Show Antigravity\\'s recently-opened folders/files (history.recentlyOpenedPathsList).',","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/antigravity/storage.js#L221-L257","documentation":"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.","triggerScenarios":"`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.","commonSituations":"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.","solutions":["List exact keys first: `opencli antigravity state-keys` (optionally --filter substring).","Copy the key verbatim from state-keys output — matching is exact.","Retry with/without --workspace to check the other database.","If the value is a user setting, use `opencli antigravity settings-read` instead."],"exampleFix":"// before\nopencli antigravity state-get recentlyOpenedPathsList\n// after\nopencli antigravity state-keys --filter recently\nopencli antigravity state-get history.recentlyOpenedPathsList","handlingStrategy":"try-catch","validationCode":"// Verify the exact key exists in the target DB before reading\nconst out = execSync('opencli antigravity state-keys' + (ws ? ` --workspace ${ws}` : ''), {encoding:'utf8'});\nif (!out.includes('history.recentlyOpenedPathsList')) throw new Error('key not present in this DB; check state-keys output for exact name');","typeGuard":"function keyInListing(listingOutput, key) {\n  return String(listingOutput).split('\\n').some((row) => row.split(/\\s{2,}/).includes(key));\n}","tryCatchPattern":"try {\n  run(`opencli antigravity state-get ${key}`);\n} catch (e) {\n  if (/^Key not found: /.test(e.message)) {\n    run(`opencli antigravity state-get ${key} --workspace ${ws}`); // try workspace DB\n  } else throw e;\n}","preventionTips":["Copy keys verbatim from state-keys output — matching is exact, no fuzzy/prefix lookup.","Check both global and --workspace DBs; key sets differ.","Don't confuse settings.json keys (settings-read) with ItemTable keys (state-get).","Key names can change between Antigravity versions — re-list rather than hardcoding."],"tags":["key-not-found","sqlite","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"}