{"record":{"id":"a43d3f3225059acd","repo":"angular/angular-cli","slug":"invalid-json-path","errorCode":null,"errorMessage":"Invalid JSON path.","messagePattern":"Invalid JSON path\\.","errorType":"validation","errorClass":"CommandModuleError","httpStatus":null,"severity":"error","filePath":"packages/angular/cli/src/commands/config/cli.ts","lineNumber":150,"sourceCode":" * by the path. For example, a path of \"a[3].foo.bar[2]\" would give you a fragment array of\n * [\"a\", 3, \"foo\", \"bar\", 2].\n * @param path The JSON string to parse.\n * @returns {(string|number)[]} The fragments for the string.\n * @private\n */\nfunction parseJsonPath(path: string): (string | number)[] {\n  const fragments = (path || '').split(/\\./g);\n  const result: (string | number)[] = [];\n\n  while (fragments.length > 0) {\n    const fragment = fragments.shift();\n    if (fragment == undefined) {\n      break;\n    }\n\n    const match = fragment.match(/([^[]+)((\\[.*\\])*)/);\n    if (!match) {\n      throw new CommandModuleError('Invalid JSON path.');\n    }\n\n    result.push(match[1]);\n    if (match[2]) {\n      const indices = match[2]\n        .slice(1, -1)\n        .split('][')\n        .map((x) => (/^\\d$/.test(x) ? +x : x.replace(/\"|'/g, '')));\n      result.push(...indices);\n    }\n  }\n\n  return result.filter((fragment) => fragment != null);\n}\n\nfunction normalizeValue(value: string | undefined | boolean | number): JsonValue | undefined {\n  const valueString = `${value}`.trim();\n  switch (valueString) {","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular/cli/src/commands/config/cli.ts#L132-L168","documentation":"parseJsonPath() converts a dot/bracket JSON path string (e.g. schematics['@scope/pkg'].style) into an array of keys/indices. Each fragment must match the regex /([^[]+)((\\[.*\\])*)/; if a fragment does not, the path is malformed and a CommandModuleError('Invalid JSON path.') is thrown.","triggerScenarios":"Supplying a jsonPath to `ng config` whose fragment has no non-bracket characters or otherwise fails the regex — e.g. a path starting with '[' (like \"[0].name\"), consecutive/empty bracket segments in a way the regex can't capture, or paths containing only brackets such as \"[\\\"cli\\\"]\".","commonSituations":"Passing array-index-first paths; quoting mistakes that leave empty fragments; using JSON-pointer style paths (/cli/x) or leading dots (.cli.x) that the parser does not accept.","solutions":["Use dot notation rooted at a key: `ng config cli.defaultCollection value` instead of `[\"cli\"].defaultCollection`","For scoped schematic packages, keep a non-bracket prefix: `ng config schematics.@angular/core.component.style scss`","Remove leading/trailing dots or brackets from the path","Verify the final argument after shell quoting is a plain path string (print it with echo)"],"exampleFix":"// before\nng config \"[cli].defaultCollection\" my-lib\n// after\nng config cli.defaultCollection my-lib","handlingStrategy":"validation","validationCode":"// Mirror of the parser's expectation: fragment must have non-bracket chars and be dot/bracket separated\nfunction isParseableJsonPath(p: string): boolean {\n  return p.split('.')\n    .filter(Boolean)\n    .every((f) => /([^[]+)((\\[.*\\])*)/.test(f));\n}\nif (!isParseableJsonPath(jsonPath)) {\n  throw new Error(`Unsupported JSON path: ${jsonPath}. Use key.subKey or key[\"subKey\"] form starting with a key name.`);\n}","typeGuard":"function isDotPrefixedPath(p: string): p is string {\n  return /^[A-Za-z0-9_@\\-]/.test(p); // must start with a key name, not '[' or '.'\n}","tryCatchPattern":"try {\n  await ngConfigSet(jsonPath, value);\n} catch (e) {\n  if (e instanceof CommandModuleError && e.message === 'Invalid JSON path.') {\n    logger.error(`Cannot parse '${jsonPath}'. Use forms like cli.analytics or schematics[\"@scope/pkg\"].style.`);\n  } else { throw e; }\n}","preventionTips":["Start paths with a plain key name, never '[' or '.'","Prefer dot notation; use bracket syntax only for keys with special characters","Test quoting: echo the exact path argument before running","Avoid JSON-pointer (/) or leading-dot (.) path styles"],"tags":["angular-cli","config","json-path","parsing"],"backgroundTag":"invalid-json-path","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}