> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/workload-map/llms.txt.

# Troubleshoot jq Paths

> Find the cause and the fix for the errors that a jq path in a Workload Map definition can produce, and learn which jq constructs a definition does not allow.

Every path in a definition is a [jq](https://jqlang.org/) expression. The errors on this page name the exact expression that failed, so search your definition for that string. For the other kinds of errors, refer to [Troubleshoot Definitions](/workload-map/troubleshooting/troubleshoot-definitions).

## Find the Field That Failed

An error from the validator names the expression and the field that holds it. The field is in the notation of the Go type, from the `Spec` root of the definition. In the following output, the expression `.spec.x[` is the `replicasPath` of the first child component:

```text
INVALID: my-workload.yaml
  failed to parse JQ expression '.spec.x[' at 'Spec.StructureDefinition.ChildComponents[0].ScaleDefinition.ReplicasPath': unexpected EOF
error: 1 finding(s) in my-workload.yaml
```

## jq Path Errors

A path can fail at two times. The validator parses every path when it validates the definition. The library compiles and runs a path when it evaluates the path against a real object.

| Error message | When | Cause | Fix |
| --- | --- | --- | --- |
| `failed to parse JQ expression '<expr>' at '<path>': ...` | Validation | The expression is not syntactically valid jq. | Fix the syntax. Common causes are unbalanced brackets or quotes, a missing leading `.`, and the wrong quote style around `["key"]`. |
| `failed to compile JQ expression '<expr>': ...` | Evaluation | The expression parses but cannot compile, for example because it references an unknown function. | Use only standard jq builtins. Check the function names and the number of arguments. |
| `JQ execution error for expression '<expr>': ...` | Evaluation | The expression compiled but failed while it ran against real data, often because of a null traversal. | Make the path null-safe. Supply defaults with `//`, for example `(.status.active // 0)` or `.spec.parallelism // 1`. |

## Constructs That a Definition Does Not Allow

The validator also checks every expression statically before the library runs it. It walks the parsed jq syntax tree, and it rejects anything that changes data or can produce unbounded output:

- Assignment and update operators: `=`, `|=`, `+=`, `-=`, `*=`, `/=`, `%=`, and `//=`.
- The `del` function.
- The recursive descent operator `..`.
- The unbounded functions `range`, `paths`, `recurse`, `walk`, and `repeat`.

| Error message | Cause | Fix |
| --- | --- | --- |
| `JQ expression '<expr>' at '<path>' failed validation: modifying operator '<op>' is not allowed` | The expression uses an assignment or update operator. | The paths of a definition read state, and they never write it. Rewrite the expression so that it only reads. |
| `JQ expression '<expr>' at '<path>' failed validation: del function is not allowed` | The expression deletes fields. | Read the value. Do not change it. |
| `JQ expression '<expr>' at '<path>' failed validation: recursive descent operator '..' is not allowed` | The expression uses `..`, which walks the whole document. | Spell out the absolute path to the field instead. |
| `JQ expression '<expr>' at '<path>' failed validation: function '<name>' may produce excessive output and is not allowed` | The expression uses an unbounded function: `range`, `paths`, `recurse`, `walk`, or `repeat`. | Use a bounded expression that addresses the fields directly. |

## Test an Expression

Test an expression against a real workload manifest with the `jq` command before you put it in a definition. The following command reproduces what Workload Map evaluates:

```bash
kubectl get <resource> -o json | jq '<expr>'
```

The [jq playground](https://play.jqlang.org/) works as well, without leaving the browser.

To check all the paths of a definition against a real workload, use `karta-verify`. It reports an expression that is valid but extracts nothing. For more information, refer to [Define a Workload Type](/workload-map/building-on-workload-map/define-a-workload-type#check-the-definition-against-a-real-workload).

## Next Steps

- To learn which object each path is evaluated against, refer to [Paths](/workload-map/reference/workload-definition-spec#paths) in the Workload Definition Spec.
- To fix a structure error, refer to [Troubleshoot Definitions](/workload-map/troubleshooting/troubleshoot-definitions).