{"record":{"id":"9a3dfc76838d0415","repo":"apple/pkl","slug":"invalidconverterpath","errorCode":"invalidConverterPath","errorMessage":"invalidConverterPath","messagePattern":"invalidConverterPath","errorType":"error_code","errorClass":"VmException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/stdlib/PathSpecParser.java","lineNumber":50,"sourceCode":"   * VmValueConverter.TOP_LEVEL_VALUE\n   */\n  Object[] parse(String pathSpec) {\n    var result = new ArrayList<>();\n\n    // 0 -> start or after leading `^`\n    // 1 -> in property\n    // 2 -> in element\n    // 3 -> after `]`\n    // 4 -> after `.*`\n    // 5 -> after `[*`\n    var state = 0;\n\n    var partStartIdx = 0;\n    var codePoints = pathSpec.codePoints().toArray();\n    for (var idx = 0; idx < codePoints.length; idx++) {\n      switch (codePoints[idx]) {\n        case '^' -> {\n          if (idx != 0) throw invalidPattern(pathSpec);\n          result.add(VmValueConverter.TOP_LEVEL_VALUE);\n          partStartIdx = 1;\n        }\n        case '.' -> {\n          switch (state) {\n            case 1 -> {\n              int count = idx - partStartIdx;\n              if (count == 0) throw invalidPattern(pathSpec);\n              result.add(Identifier.get(new String(codePoints, partStartIdx, count)));\n            }\n            case 3, 4 -> {}\n            default -> throw invalidPattern(pathSpec);\n          }\n          partStartIdx = idx + 1;\n          state = 1;\n        }\n        case '[' -> {\n          switch (state) {","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/stdlib/PathSpecParser.java#L32-L68","documentation":"Pkl's path-based output converters (e.g. `output.converters` with `xml`/`json` path specs) use PathSpecParser.parse to parse a path spec string into path parts. The '^' character may only appear at index 0 of the spec, where it denotes the top-level value; anywhere else the spec is syntactically invalid and this evalError is thrown. The error message is `invalidConverterPath` followed by the offending path spec.","triggerScenarios":"Calling PathSpecParser.parse (via a Pkl path-based output converter) with a spec containing '^' at any position other than the first character, e.g. `foo^.bar` or `a.^`.","commonSituations":"Typo in an output converter path spec in a Pkl module, concatenating specs where '^' ends up mid-string, copying a spec snippet that includes the top-level marker into a sub-path.","solutions":["Remove the '^' from non-leading positions; '^' is only valid as the first character.","If you meant to target the top-level value, use a spec that is exactly \"^\" or start the spec with '^' followed by the rest of the path (e.g. \"^.foo\").","Re-check the path spec syntax: properties are separated by '.', element keys are in '[...]'."],"exampleFix":"// before\nconverter.pathSpec = \"foo^.bar\"\n// after\nconverter.pathSpec = \"foo.bar\"","handlingStrategy":"validation","validationCode":"function isValidPklPathSpec(spec) {\n  return typeof spec === \"string\" && (spec.indexOf(\"^\") === -1 || spec.startsWith(\"^\"));\n}","typeGuard":null,"tryCatchPattern":"try {\n  render(converter)\n} catch (e) {\n  if (String(e.message).includes(\"invalidConverterPath\")) {\n    throw new Error(`Malformed Pkl path spec: ${pathSpec}`);\n  }\n  throw e;\n}","preventionTips":["Only use '^' as the very first character of a path spec","Validate specs against the documented grammar before assigning them to converters","Avoid concatenating path fragments that could embed '^' mid-string"],"tags":["pkl","path-spec","parser","converter"],"backgroundTag":"invalid-argument-format","analyzedSha":"f3efcbfc9b60d30053b0536d664948d7aa1b8673","analyzedAt":"2026-09-08T13:10:45.570Z","contentChangedAt":"2026-09-08T13:10:45.570Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}