Claus Ibsen created CAMEL-24838:
-----------------------------------
Summary: jsonpath and jq: say that the body is null (and how to
load one) instead of 'Cannot read body as supported JSON value'
Key: CAMEL-24838
URL: https://issues.apache.org/jira/browse/CAMEL-24838
Project: Camel
Issue Type: Improvement
Components: camel-jsonpath, camel-jq
Reporter: Claus Ibsen
On a route with no body (a timer route, a step before the file was read), a
jsonpath expression fails with
{code}
org.apache.camel.ExpressionEvaluationException:
org.apache.camel.CamelExchangeException: Cannot read body as supported JSON
value. Exchange[...]
{code}
and jq with
{code}
org.apache.camel.InvalidPayloadException: No body available of type:
com.fasterxml.jackson.databind.JsonNode on: Message. Exchange[...]
{code}
Neither says the one thing that matters: the body is null. Both should, in the
style of the xslt message from CAMEL-24698: "The jsonpath expression got no
message body to evaluate (the body is null): read the JSON before the step with
poll: file:..., pollEnrich or a from: consumer, or set it with setBody." When
the body is not null but not JSON, keep the current message and add the body's
type.
Found in the round-2 local-model benchmark on the camel-jbang-examples ladder
(json-transform: a timer route with jsonpath and jq steps and no body). A
person who puts the jsonpath step before the file read gets the same two
messages.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)