{"record":{"id":"e92657c660fbc649","repo":"kestra-io/kestra","slug":"unable-to-parse-jq-value-with-type","errorCode":null,"errorMessage":"Unable to parse jq value '{}' with type '{}'","messagePattern":"Unable to parse jq value '(.+?)' with type '(.+?)'","errorType":"exception","errorClass":"PebbleException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/io/kestra/core/runners/pebble/filters/JqFilter.java","lineNumber":90,"sourceCode":"                    } else if (v instanceof NumericNode) {\n                        out.add(v.numberValue());\n                    } else if (v instanceof BooleanNode) {\n                        out.add(v.booleanValue());\n                    } else if (v instanceof ObjectNode) {\n                        out.add(JacksonMapper.ofJson().convertValue(v, Map.class));\n                    } else if (v instanceof ArrayNode) {\n                        out.add(JacksonMapper.ofJson().convertValue(v, List.class));\n                    } else {\n                        out.add(v);\n                    }\n                });\n            } catch (Exception e) {\n                throw new Exception(\"Failed to resolve JQ expression '\" + pattern + \"' and value '\" + input + \"'\", e);\n            }\n\n            return out;\n        } catch (Exception e) {\n            throw new PebbleException(e, \"Unable to parse jq value '\" + input + \"' with type '\" + input.getClass().getName() + \"'\", lineNumber, self.getName());\n        }\n    }\n}\n","sourceCodeStart":72,"sourceCodeEnd":94,"githubUrl":"https://github.com/kestra-io/kestra/blob/823fada9274c4f9c251ea0a516460a4f7d958032/core/src/main/java/io/kestra/core/runners/pebble/filters/JqFilter.java#L72-L94","documentation":"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.","triggerScenarios":"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).","commonSituations":"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).","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."],"exampleFix":"# before - string is not JSON\n{{ outputs.api.body | jq(expression=\".user.id\") }}\n# after - parse first\n{% set parsed = outputs.api.body | json %}\n{{ parsed | jq(expression=\".user.id\") }}","handlingStrategy":"validation","validationCode":"# If input is a String, parse it to JSON first so jq receives a tree:\n{% set parsed = (jsonString is string ? (jsonString | json) : jsonString) %}\n{{ parsed | jq(expression=\".id\") }}","typeGuard":"# In a script task, verify Jackson can parse before exposing to the template:\n# JsonNode node = JacksonMapper.ofJson().readTree(value);","tryCatchPattern":null,"preventionTips":["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."],"tags":["pebble-filter","jq","json","parse-error","jackson"],"backgroundTag":null,"analyzedSha":"823fada9274c4f9c251ea0a516460a4f7d958032","analyzedAt":"2026-08-14T06:15:17.947Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}