{"record":{"id":"b6718178839764aa","repo":"jackwener/OpenCLI","slug":"key-not-found-key-b67181","errorCode":null,"errorMessage":"Key not found: ${key}","messagePattern":"Key not found: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/trae-solo/state-fs.js","lineNumber":101,"sourceCode":"    name: 'state-get',\n    access: 'read',\n    description: 'Read a single key from Trae SOLO\\'s globalStorage state.vscdb. Pass --workspace <ws-id> to query a per-workspace DB instead. Returns parsed JSON if the value is JSON.',\n    domain: 'localhost',\n    browser: false,\n    strategy: Strategy.LOCAL,\n    args: [\n        { name: 'key', positional: true, required: true, help: 'State key (use state-keys to discover)' },\n        { name: 'workspace', required: false, help: 'Workspace id (from workspaces-list) to query a per-workspace DB' },\n        { name: 'max-bytes', type: 'int', required: false, default: 8000, help: 'Truncate value to this many bytes' },\n    ],\n    columns: ['Field', 'Value'],\n    func: async (args) => {\n        const key = String(args.key || '').trim();\n        if (!key) throw new ArgumentError('key required');\n        const db = resolveStateDb(args);\n        const val = getValue(db, key);\n        if (val === null) {\n            throw new CommandExecutionError(`Key not found: ${key}`, 'List available keys with `opencli trae-solo state-keys`.');\n        }\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, use --max-bytes to read more)' : valStr },\n        ];\n    },\n});\n\n// -------- recent-workspaces --------\ncli({\n    site: 'trae-solo',\n    name: 'recent-workspaces',\n    access: 'read',","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/trae-solo/state-fs.js#L83-L119","documentation":"A CommandExecutionError from state-get when the requested key is absent from the resolved state.vscdb — getValue returned null. The key string was accepted (non-empty) but no row matches it in the ItemTable.","triggerScenarios":"Calling state-get with a key that was never written, was deleted, or exists only in a different DB (global vs per-workspace), or under different casing.","commonSituations":"Key name differs across Trae versions; assuming global keys exist in workspace DBs; typos in dotted key names like 'history.recentlyOpenedPathsList'.","solutions":["Run `opencli trae-solo state-keys` (with the same --workspace if used) and pick the exact key.","Check casing and spelling of the dotted key.","Switch DB: query without --workspace or with the correct workspace id.","If the key should exist, open Trae once so it writes state before re-querying."],"exampleFix":"// before\nopencli trae-solo state-get --key history.recentlyOpenedPathList\n// after\nopencli trae-solo state-keys --filter recently\nopencli trae-solo state-get --key history.recentlyOpenedPathsList","handlingStrategy":"fallback","validationCode":"const keys = listKeys(db);\nif (!keys.includes(key)) throw new Error(`key \"${key}\" not in DB; nearest: ${keys.filter(k => k.includes(key.split('.')[0])).slice(0,5)}`);","typeGuard":null,"tryCatchPattern":"try {\n  return await stateGet({ key });\n} catch (e) {\n  if (/Key not found/.test(e.message)) return null; // treat as absent value, not fatal\n  throw e;\n}","preventionTips":["Confirm exact key spelling/casing via state-keys before state-get","Match the DB scope: same --workspace flag for keys and get","Treat not-found as a normal outcome when probing optional keys","Re-check key names after Trae version upgrades"],"tags":["key-lookup","cli","state-db"],"backgroundTag":"key-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}