{"record":{"id":"8119b6a3930b454c","repo":"usebruno/bruno","slug":"workspace-configuration-must-be-an-object","errorCode":null,"errorMessage":"Workspace configuration must be an object","messagePattern":"Workspace configuration must be an object","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/bruno-electron/src/utils/workspace-config.js","lineNumber":298,"sourceCode":"  } else {\n    yamlLines.push('docs: \\'\\'');\n  }\n\n  yamlLines.push('');\n\n  return yamlLines.join('\\n');\n};\n\nconst writeWorkspaceConfig = async (workspacePath, config) => {\n  return withLock(getWorkspaceLockKey(workspacePath), async () => {\n    const yamlContent = generateYamlContent(config);\n    await writeWorkspaceFileAtomic(workspacePath, yamlContent);\n  });\n};\n\nconst validateWorkspaceConfig = (config) => {\n  if (!config || typeof config !== 'object') {\n    throw new Error('Workspace configuration must be an object');\n  }\n\n  const type = config.info?.type || config.type;\n  if (type !== WORKSPACE_TYPE) {\n    throw new Error('Invalid workspace: not a bruno workspace');\n  }\n\n  const name = config.info?.name || config.name;\n  if (!name || typeof name !== 'string') {\n    throw new Error('Workspace must have a valid name');\n  }\n\n  return true;\n};\n\nconst updateWorkspaceName = async (workspacePath, newName) => {\n  return withLock(getWorkspaceLockKey(workspacePath), async () => {\n    const config = readWorkspaceConfig(workspacePath);","sourceCodeStart":280,"sourceCodeEnd":316,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-electron/src/utils/workspace-config.js#L280-L316","documentation":"`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.","triggerScenarios":"Calling `validateWorkspaceConfig` with `null`, an array, a string, or a number instead of a parsed workspace config object.","commonSituations":"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.","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."],"exampleFix":"// before\nvalidateWorkspaceConfig(yamlString);   // raw string, not parsed\n\n// after\nvalidateWorkspaceConfig(yaml.load(yamlString));","handlingStrategy":"type-guard","validationCode":"function assertConfigObject(cfg) {\n  if (!cfg || typeof cfg !== 'object' || Array.isArray(cfg)) {\n    throw new Error('Workspace configuration must be an object');\n  }\n  return cfg;\n}","typeGuard":"function isWorkspaceConfigObject(cfg: unknown): cfg is Record<string, unknown> {\n  return typeof cfg === 'object' && cfg !== null && !Array.isArray(cfg);\n}","tryCatchPattern":null,"preventionTips":["Always parse raw strings before validation.","Build configs with createWorkspaceConfig."],"tags":["workspace","config","validation","typescript"],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}