usebruno/bruno · error · Error

Workspace path is required

Error message

Workspace path is required

What it means

`validateWorkspacePath` rejects a falsy `workspacePath` argument before it ever touches the filesystem. It is the first guard in the workspace-config validation chain; callers must hand it a real directory path.

Source

Thrown at packages/bruno-electron/src/utils/workspace-config.js:169

const normalizeCollectionEntry = (workspacePath, collection) => {
  const relativePath = makeRelativePath(workspacePath, collection.path);

  const normalizedCollection = {
    name: collection.name,
    path: relativePath
  };

  if (collection.remote) {
    normalizedCollection.remote = collection.remote;
  }

  return normalizedCollection;
};

const validateWorkspacePath = (workspacePath) => {
  if (!workspacePath) {
    throw new Error('Workspace path is required');
  }

  if (!fs.existsSync(workspacePath)) {
    throw new Error(`Workspace path does not exist: ${workspacePath}`);
  }

  const workspaceFilePath = path.join(workspacePath, 'workspace.yml');
  if (!fs.existsSync(workspaceFilePath)) {
    throw new Error('Invalid workspace: workspace.yml not found');
  }

  return true;
};

const validateWorkspaceDirectory = (dirPath) => {
  if (!validateName(path.basename(dirPath))) {
    throw new Error(`Invalid workspace directory name: ${dirPath}`);
  }

View on GitHub (pinned to 9bdd81c7bd)

Solutions

  1. Pass the absolute directory path returned by the folder picker / persisted workspace record.
  2. Check the caller (IPC handler, store) to confirm `workspacePath` is populated before invoking.
  3. Surface a user-facing 'select a workspace' prompt instead of calling the validator with nothing.

Example fix

// before
validateWorkspacePath(undefined);

// after
validateWorkspacePath(selectedWorkspace.path);
Defensive patterns

Strategy: validation

Validate before calling

function ensureWorkspacePath(p) {
  if (!p || typeof p !== 'string') {
    throw new Error('Select a workspace before continuing.');
  }
  return p;
}
const wsPath = ensureWorkspacePath(selectedWorkspace?.path);

Type guard

function isNonEmptyString(value: unknown): value is string {
  return typeof value === 'string' && value.trim().length > 0;
}

Try / catch

try { validateWorkspacePath(wsPath); }
catch (e) { /* prompt user to pick a workspace */ }

Prevention

When it happens

Trigger: Any caller passes `undefined`, `null`, `''`, or `0` as `workspacePath` to `validateWorkspacePath` — typically a missing argument from an IPC handler or a destructured config field that was absent.

Common situations: An Electron IPC event that forgot to forward `workspacePath`; a fresh install where the path was never selected; a refactor that renamed the field; a test that called the function with no args.

Related errors


AI-assisted analysis of usebruno/bruno@9bdd81c7bd (2026-08-13). Data as JSON: /api/errors/bb76afdddb05c588. Report an issue: GitHub.