usebruno/bruno · error · Error
Workspace configuration must be an object
Error message
Workspace configuration must be an object
What it means
`validateWorkspaceConfig` first asserts the config is a non-null object; used on programmatically-supplied configs (before write/normalize). It catches callers passing primitives, arrays, or null where a config map is required.
Source
Thrown at packages/bruno-electron/src/utils/workspace-config.js:298
} else {
yamlLines.push('docs: \'\'');
}
yamlLines.push('');
return yamlLines.join('\n');
};
const writeWorkspaceConfig = async (workspacePath, config) => {
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);View on GitHub (pinned to 9bdd81c7bd)
Solutions
- Ensure the value passed is the parsed config object, not the raw YAML/JSON string.
- Add an upstream type check (`typeof config === 'object' && config !== null && !Array.isArray(config)`).
- Construct configs via `createWorkspaceConfig` rather than ad-hoc literals.
Example fix
// before validateWorkspaceConfig(yamlString); // raw string, not parsed // after validateWorkspaceConfig(yaml.load(yamlString));
Defensive patterns
Strategy: type-guard
Validate before calling
function assertConfigObject(cfg) {
if (!cfg || typeof cfg !== 'object' || Array.isArray(cfg)) {
throw new Error('Workspace configuration must be an object');
}
return cfg;
} Type guard
function isWorkspaceConfigObject(cfg: unknown): cfg is Record<string, unknown> {
return typeof cfg === 'object' && cfg !== null && !Array.isArray(cfg);
} Prevention
- Always parse raw strings before validation.
- Build configs with createWorkspaceConfig.
When it happens
Trigger: Calling `validateWorkspaceConfig` with `null`, an array, a string, or a number instead of a parsed workspace config object.
Common situations: A caller forgot to parse YAML/JSON and passed a raw string; an empty array was supplied for `collections`-shaped input; a `JSON.parse` returned a primitive; defensive path invoked after a failed cast.
Related errors
- Workspace path is required
- Invalid workspace: not a bruno workspace
- Workspace must have a valid name
- Invalid collection: name and path are required
- Invalid API spec: name and path are required
AI-assisted analysis of usebruno/bruno@9bdd81c7bd (2026-08-13).
Data as JSON: /api/errors/8119b6a3930b454c.
Report an issue: GitHub.