{"record":{"id":"e3405a2569ccb8f0","repo":"angular/angular-cli","slug":"message-e3405a","errorCode":null,"errorMessage":"${message}","messagePattern":"\\$\\{message\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/angular_devkit/core/src/workspace/json/reader.ts","lineNumber":80,"sourceCode":"  if (version !== 1) {\n    throw new Error(`Invalid format version detected - Expected:[ 1 ] Found: [ ${version} ]`);\n  }\n\n  const context: ParserContext = {\n    host,\n    metadata: new JsonWorkspaceMetadata(path, ast, raw),\n    trackChanges: true,\n    unprefixedWorkspaceExtensions: new Set([\n      ...ANGULAR_WORKSPACE_EXTENSIONS,\n      ...(options.allowedWorkspaceExtensions ?? []),\n    ]),\n    unprefixedProjectExtensions: new Set([\n      ...ANGULAR_PROJECT_EXTENSIONS,\n      ...(options.allowedProjectExtensions ?? []),\n    ]),\n    error(message, _node) {\n      // TODO: Diagnostic reporting support\n      throw new Error(message);\n    },\n    warn(message, _node) {\n      // TODO: Diagnostic reporting support\n      // eslint-disable-next-line no-console\n      console.warn(message);\n    },\n  };\n\n  const workspace = parseWorkspace(ast, context);\n\n  return workspace;\n}\n\nfunction parseWorkspace(workspaceNode: Node, context: ParserContext): WorkspaceDefinition {\n  const jsonMetadata = context.metadata;\n  let projects;\n  let extensions: Record<string, JsonValue> | undefined;\n  if (!context.trackChanges) {","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular_devkit/core/src/workspace/json/reader.ts#L62-L98","documentation":"The workspace JSON reader registers an `error` callback with the JSON parser that unconditionally throws a plain `Error(message)`. Whenever the parser encounters invalid JSON or workspace content that violates the parser's expectations, this callback fires with a descriptive message. It is the generic parse-failure path for workspace (angular.json) parsing; diagnostic reporting is not yet wired up, so the raw parser message is surfaced as a thrown error.","triggerScenarios":"Calling parseWorkspace/parseProject on content where the JSON parser's error callback fires: malformed JSON syntax, wrong node types where structures are expected, or other parser-level validation failures inside angular_devkit/core's JSON AST parser.","commonSituations":"Hand-edited angular.json with a syntax error (trailing comma, unquoted key); a tool wrote non-JSON content to the workspace file; encoding/BOM issues in the config file.","solutions":["Validate angular.json with JSON.parse or a linter to find the syntax error at the location named in the message","Restore the workspace file from version control or regenerate it (e.g. `ng new` comparison)","If thrown on programmatically supplied content, fix the JSON string/AST before passing it to parseWorkspace"],"exampleFix":"// before\nconst workspace = JSON.parse(fs.readFileSync('angular.json', 'utf8').replace(/^\\ufeff/, ''));\nparseWorkspace(host, logger, workspaceText, options);\n// after\nlet workspaceText = fs.readFileSync('angular.json', 'utf8');\ntry {\n  JSON.parse(workspaceText); // validate first\n} catch (e) {\n  workspaceText = workspaceText.replace(/^\\ufeff/, '');\n  JSON.parse(workspaceText); // surface precise JSON syntax error\n}\nparseWorkspace(host, logger, workspaceText, options);","handlingStrategy":"try-catch","validationCode":"try { JSON.parse(workspaceText); } catch (e) { throw new Error(`angular.json is not valid JSON: ${e.message}`); }","typeGuard":null,"tryCatchPattern":"let workspace;\ntry {\n  workspace = await parseWorkspace(host, logger, text, options);\n} catch (err) {\n  // reader throws plain Error with the parser message\n  console.error(`Failed to parse workspace: ${err.message}`);\n  process.exitCode = 1;\n}","preventionTips":["Validate angular.json with JSON.parse or a JSON schema linter in CI before running workspace tooling","Strip BOM and enforce UTF-8 when writing config files","Never hand-edit angular.json without running a JSON formatter afterwards"],"tags":["json","parse-error","workspace","angular-cli"],"backgroundTag":"invalid-json-config","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}