jackwener/OpenCLI · error · CommandExecutionError
Key not found: ${key}
Error message
Key not found: ${key} What it means
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.
Source
Thrown at clis/trae-solo/state-fs.js:101
name: 'state-get',
access: 'read',
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.',
domain: 'localhost',
browser: false,
strategy: Strategy.LOCAL,
args: [
{ name: 'key', positional: true, required: true, help: 'State key (use state-keys to discover)' },
{ name: 'workspace', required: false, help: 'Workspace id (from workspaces-list) to query a per-workspace DB' },
{ name: 'max-bytes', type: 'int', required: false, default: 8000, help: 'Truncate value to this many bytes' },
],
columns: ['Field', 'Value'],
func: async (args) => {
const key = String(args.key || '').trim();
if (!key) throw new ArgumentError('key required');
const db = resolveStateDb(args);
const val = getValue(db, key);
if (val === null) {
throw new CommandExecutionError(`Key not found: ${key}`, 'List available keys with `opencli trae-solo state-keys`.');
}
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, use --max-bytes to read more)' : valStr },
];
},
});
// -------- recent-workspaces --------
cli({
site: 'trae-solo',
name: 'recent-workspaces',
access: 'read',View on GitHub (pinned to 49907e53dc)
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.
Example fix
// before opencli trae-solo state-get --key history.recentlyOpenedPathList // after opencli trae-solo state-keys --filter recently opencli trae-solo state-get --key history.recentlyOpenedPathsList
Defensive patterns
Strategy: fallback
Validate before calling
const keys = listKeys(db);
if (!keys.includes(key)) throw new Error(`key "${key}" not in DB; nearest: ${keys.filter(k => k.includes(key.split('.')[0])).slice(0,5)}`); Try / catch
try {
return await stateGet({ key });
} catch (e) {
if (/Key not found/.test(e.message)) return null; // treat as absent value, not fatal
throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: Key name differs across Trae versions; assuming global keys exist in workspace DBs; typos in dotted key names like 'history.recentlyOpenedPathsList'.
Related errors
- No recent workspaces recorded.
- Not a git repository
- Working tree not clean: ${status}
- Stale .git/index.lock found — remove it first
- 12306 whoami failed: ${probe.detail}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/b6718178839764aa.
Report an issue: GitHub.