jackwener/OpenCLI · error · CommandExecutionError

Workspace state.vscdb not found: ${db}

Error message

Workspace state.vscdb not found: ${db}

What it means

resolveStateDb builds a path <TRAE_WORKSPACE_STORAGE>/<workspace-id>/state.vscdb and throws when that file does not exist. It only validates existence when a --workspace argument is supplied; the global DB is returned unchecked. The error means the supplied workspace id does not correspond to an actual workspaceStorage folder.

Source

Thrown at clis/trae-solo/state-fs.js:39

    ArgumentError,
    CommandExecutionError,
    EmptyResultError,
} from '@jackwener/opencli/errors';
import {
    TRAE_GLOBAL_STATE_DB,
    TRAE_WORKSPACE_STORAGE,
    listKeys,
    getValue,
} from './_state.js';

// Resolve the actual state.vscdb to read. With no --workspace, uses the
// global state DB. With --workspace <id>, uses that workspaceStorage DB.
function resolveStateDb(args) {
    const ws = args.workspace ? String(args.workspace).trim() : '';
    if (!ws) return TRAE_GLOBAL_STATE_DB;
    const db = path.join(TRAE_WORKSPACE_STORAGE, ws, 'state.vscdb');
    if (!fs.existsSync(db)) {
        throw new CommandExecutionError(
            `Workspace state.vscdb not found: ${db}`,
            'List valid workspace ids with `opencli trae-solo workspaces-list`.',
        );
    }
    return db;
}

// -------- state-keys --------
cli({
    site: 'trae-solo',
    name: 'state-keys',
    access: 'read',
    description: 'List all keys present in Trae SOLO\'s globalStorage state.vscdb (VSCode-style UI/agent state). Pass --workspace <ws-id> to query a per-workspace DB instead. Use state-get to read a specific value. (See renderer storage-keys for browser-side LS/SS.)',
    domain: 'localhost',
    browser: false,
    strategy: Strategy.LOCAL,
    args: [
        { name: 'filter', required: false, help: 'Case-insensitive substring filter over keys' },

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Run `opencli trae-solo workspaces-list` and copy an exact, currently valid workspace id.
  2. Confirm the file exists at <TRAE_WORKSPACE_STORAGE>/<id>/state.vscdb (ls the directory) before passing --workspace.
  3. Omit --workspace to query the global TRAE_GLOBAL_STATE_DB instead.
  4. If the workspace was removed, re-open it once in Trae so its state.vscdb is recreated.

Example fix

// before
opencli trae-solo state-get --workspace abc123
// after
opencli trae-solo workspaces-list   # pick a valid id
opencli trae-solo state-get --workspace 3f9c...  # exact folder name
Defensive patterns

Strategy: validation

Validate before calling

const fs = require('fs'), path = require('path');
const db = path.join(TRAE_WORKSPACE_STORAGE, ws, 'state.vscdb');
if (!ws.trim()) throw new Error('workspace id required');
if (!fs.existsSync(db)) throw new Error(`workspace db missing: ${db} — run workspaces-list`);

Type guard

function isValidWorkspaceId(ws) { return typeof ws === 'string' && /^[A-Za-z0-9-]{8,}$/.test(ws.trim()); }

Try / catch

try {
  const db = resolveStateDb(args);
  // ...
} catch (e) {
  if (/state.vscdb not found/.test(e.message)) {
    console.error('Run: opencli trae-solo workspaces-list');
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling any trae-solo state command (state-keys, state-get, etc.) with --workspace set to an id whose folder has no state.vscdb, a mistyped/truncated id, or a workspace that was deleted from workspaceStorage.

Common situations: Typo or partial copy-paste of the workspace UUID; stale id from an old workspaces-list after Trae cleaned storage; pointing the CLI at a machine/user profile where the workspace never existed; Trae version change moving workspaceStorage.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


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