{"record":{"id":"2ea842539e49d12d","repo":"angular/angular-cli","slug":"invalid-config-found-at-workspace-filepath-cli","errorCode":null,"errorMessage":"Invalid config found at ${workspace.filePath}. CLI should be an object.","messagePattern":"Invalid config found at (.+?)\\. CLI should be an object\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/angular/cli/src/analytics/analytics.ts","lineNumber":54,"sourceCode":"    }\n  });\n}\n\n/**\n * Set analytics settings. This does not work if the user is not inside a project.\n * @param global Which config to use. \"global\" for user-level, and \"local\" for project-level.\n * @param value Either a user ID, true to generate a new User ID, or false to disable analytics.\n */\nexport async function setAnalyticsConfig(global: boolean, value: string | boolean): Promise<void> {\n  const level = global ? 'global' : 'local';\n  const workspace = await getWorkspace(level);\n  if (!workspace) {\n    throw new Error(`Could not find ${level} workspace.`);\n  }\n\n  const cli = (workspace.extensions['cli'] ??= {});\n  if (!workspace || !json.isJsonObject(cli)) {\n    throw new Error(`Invalid config found at ${workspace.filePath}. CLI should be an object.`);\n  }\n\n  cli.analytics = value === true ? randomUUID() : value;\n  await workspace.save();\n}\n\n/**\n * Prompt the user for usage gathering permission.\n * @param force Whether to ask regardless of whether or not the user is using an interactive shell.\n * @return Whether or not the user was shown a prompt.\n */\nexport async function promptAnalytics(\n  context: CommandContext,\n  global: boolean,\n  force = false,\n): Promise<boolean> {\n  const level = global ? 'global' : 'local';\n  const workspace = await getWorkspace(level);","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular/cli/src/analytics/analytics.ts#L36-L72","documentation":"After loading the workspace config, setAnalyticsConfig validates that the 'cli' extension entry is a JSON object before assigning cli.analytics. If the config file exists but its 'cli' section (or structure) is not an object, it throws this error including the offending config file path.","triggerScenarios":"A global or local Angular config file where 'cli' is a string, number, array or null (e.g. hand-edited angular.json or ~/.angular-config.json with \"cli\": \"disabled\"), or corrupted/malformed config merging.","commonSituations":"Manual edits to angular.json; copy-pasted config snippets; older config formats after CLI upgrades; tools that rewrote the config incorrectly.","solutions":["Open the file named in the error and make the 'cli' key an object, e.g. {\"cli\": {\"analytics\": false}}","Validate angular.json is valid JSON with a JSON linter","Restore the config from version control or regenerate it","Remove the malformed 'cli' key and re-run the analytics command to recreate it"],"exampleFix":"// before (angular.json extensions)\n\"cli\": \"disabled\"\n// after\n\"cli\": {\"analytics\": false}","handlingStrategy":"validation","validationCode":"import { readFileSync } from 'fs';\nconst cfg = JSON.parse(readFileSync('angular.json', 'utf8'));\nconst cli = cfg.cli ?? cfg.extensions?.cli;\nif (cli !== undefined && (typeof cli !== 'object' || cli === null || Array.isArray(cli))) {\n  throw new Error('cli section must be an object');\n}","typeGuard":"function isJsonObject(v: unknown): v is Record<string, unknown> {\n  return typeof v === 'object' && v !== null && !Array.isArray(v);\n}","tryCatchPattern":"try {\n  await setAnalyticsConfig(global, value);\n} catch (e) {\n  if ((e as Error).message.startsWith('Invalid config found at')) {\n    const filePath = (e as Error).message.match(/at (.+)\\./)?.[1];\n    // repair or restore the named config file\n  } else throw e;\n}","preventionTips":["Never set \"cli\" to a plain string in angular.json","Edit config with 'ng config' instead of by hand","Validate angular.json with a JSON schema linter","Keep config files in version control to diff/restore bad edits"],"tags":["angular-cli","config","json","validation"],"backgroundTag":"invalid-config-format","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}