kestra-io/kestra · error · PebbleException
Unable to parse jq value '{}' with type '{}'
Error message
Unable to parse jq value '{}' with type '{}' What it means
Thrown by the 'jq' Pebble filter when either the jq expression fails to compile/apply or the input cannot be converted to a JsonNode. The filter wraps any exception from `JsonQuery.compile`, `JacksonMapper.ofJson().readTree(stringValue)` (for String input), `valueToTree(input)` (for other types), or the jq evaluation callback. The message echoes the raw input value and its Java class to aid diagnosis.
Source
Thrown at core/src/main/java/io/kestra/core/runners/pebble/filters/JqFilter.java:90
} else if (v instanceof NumericNode) {
out.add(v.numberValue());
} else if (v instanceof BooleanNode) {
out.add(v.booleanValue());
} else if (v instanceof ObjectNode) {
out.add(JacksonMapper.ofJson().convertValue(v, Map.class));
} else if (v instanceof ArrayNode) {
out.add(JacksonMapper.ofJson().convertValue(v, List.class));
} else {
out.add(v);
}
});
} catch (Exception e) {
throw new Exception("Failed to resolve JQ expression '" + pattern + "' and value '" + input + "'", e);
}
return out;
} catch (Exception e) {
throw new PebbleException(e, "Unable to parse jq value '" + input + "' with type '" + input.getClass().getName() + "'", lineNumber, self.getName());
}
}
}
View on GitHub (pinned to 823fada927)
Solutions
- If input is a String, ensure it parses as JSON (use `| json` or validate upstream).
- Test the jq expression in an external jq 1.6 playground first.
- If the input is already a Map/List, pass it directly rather than re-serializing to a String.
- Read the wrapped cause in the stack trace for the exact jq/Jackson error.
Example fix
# before - string is not JSON
{{ outputs.api.body | jq(expression=".user.id") }}
# after - parse first
{% set parsed = outputs.api.body | json %}
{{ parsed | jq(expression=".user.id") }} Defensive patterns
Strategy: validation
Validate before calling
# If input is a String, parse it to JSON first so jq receives a tree:
{% set parsed = (jsonString is string ? (jsonString | json) : jsonString) %}
{{ parsed | jq(expression=".id") }} Type guard
# In a script task, verify Jackson can parse before exposing to the template: # JsonNode node = JacksonMapper.ofJson().readTree(value);
Prevention
- Always parse String inputs with the `json` filter before `jq`.
- Validate jq expressions in a jq 1.6 playground (Kestra bundles 1.6 only).
- Pass Maps/Lists directly to jq instead of re-serializing them.
When it happens
Trigger: Passing a String input that is not valid JSON (readTree throws); passing a malformed jq expression; passing an input whose type Jackson cannot serialize to a tree; a jq expression that triggers an error during evaluation (e.g. dividing by zero in jq, or applying an operator to an incompatible type).
Common situations: Feeding a plain text or XML body to `jq` instead of JSON; jq expression referencing a field that does not exist on a scalar; version mismatch between the jq syntax used and jq 1.6 (the only version Kestra bundles).
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- The 'jq' filter expects an argument 'expression'.
- Unable to transform to json value '{input}' with type '{inpu
- Invalid json: {e.getMessage()}
- Failed to read secret sub-key '%s' from secret '%s'. Ensure
- QueryFilter must be either a leaf (field + operation) or a n
AI-assisted analysis of kestra-io/kestra@823fada927 (2026-08-14).
Data as JSON: /api/errors/e92657c660fbc649.
Report an issue: GitHub.