usebruno/bruno · error · Error

Workspace must have a valid name

Error message

Workspace must have a valid name

What it means

`validateWorkspaceConfig` requires a non-empty string name at `config.info?.name || config.name`. Without a name the workspace is rejected even if the type is correct.

Source

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

  return withLock(getWorkspaceLockKey(workspacePath), async () => {
    const yamlContent = generateYamlContent(config);
    await writeWorkspaceFileAtomic(workspacePath, yamlContent);
  });
};

const validateWorkspaceConfig = (config) => {
  if (!config || typeof config !== 'object') {
    throw new Error('Workspace configuration must be an object');
  }

  const type = config.info?.type || config.type;
  if (type !== WORKSPACE_TYPE) {
    throw new Error('Invalid workspace: not a bruno workspace');
  }

  const name = config.info?.name || config.name;
  if (!name || typeof name !== 'string') {
    throw new Error('Workspace must have a valid name');
  }

  return true;
};

const updateWorkspaceName = async (workspacePath, newName) => {
  return withLock(getWorkspaceLockKey(workspacePath), async () => {
    const config = readWorkspaceConfig(workspacePath);
    config.name = newName;
    if (config.info) {
      config.info.name = newName;
    }
    const yamlContent = generateYamlContent(config);
    await writeWorkspaceFileAtomic(workspacePath, yamlContent);
    return config;
  });
};

View on GitHub (pinned to 9bdd81c7bd)

Solutions

  1. Add `info.name: <non-empty string>` to `workspace.yml`.
  2. When creating programmatically, always pass a non-empty name to `createWorkspaceConfig`.
  3. Validate the name field in any UI rename form before submitting.

Example fix

// before
info:
  type: workspace

// after
info:
  name: MyWorkspace
  type: workspace
Defensive patterns

Strategy: validation

Validate before calling

function assertWorkspaceName(cfg) {
  const name = cfg?.info?.name || cfg?.name;
  if (typeof name !== 'string' || name.trim() === '') {
    throw new Error('Workspace must have a valid name');
  }
}

Type guard

function hasValidWorkspaceName(cfg: unknown): boolean {
  if (typeof cfg !== 'object' || cfg === null) return false;
  const name = (cfg as any).info?.name ?? (cfg as any).name;
  return typeof name === 'string' && name.trim().length > 0;
}

Prevention

When it happens

Trigger: A parsed config with `type: workspace` but `info.name`/`name` that is undefined, empty, or not a string.

Common situations: Hand-edited `workspace.yml` with the `name` line removed; a write that set name to `''`; a migration that dropped the field; rename operation that stored a blank.

Related errors


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