[
https://issues.apache.org/jira/browse/CAMEL-24931?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18118343#comment-18118343
]
Claus Ibsen commented on CAMEL-24931:
-------------------------------------
Implemented in PR https://github.com/apache/camel/pull/26780
Both forms in the new message were verified by running them rather than taken
from the docs: {{setBody: constant: resource:file:stock.json}} fills the body
with the file text and jsonpath then reads it, and {{poll:}} with
{{file:inbox}} and {{delete: true}} reads the file and deletes it.
Tests in {{JsonPathNullBodyHintTest}} and {{JqNullBodyHintTest}} assert the
form, the alternative and the reason, so the message cannot drift back to
naming only the mechanism.
> camel-jsonpath, camel-jq: the null body hint says how to read the data, not
> only that it must be read
> -----------------------------------------------------------------------------------------------------
>
> Key: CAMEL-24931
> URL: https://issues.apache.org/jira/browse/CAMEL-24931
> Project: Camel
> Issue Type: Improvement
> Components: camel-jsonpath
> Reporter: Claus Ibsen
> Priority: Minor
>
> A route reached with {{direct:}} has the body of its caller. When the caller
> has none - a REST GET, a timer - a {{jsonpath}} or {{jq}} step in that route
> has nothing to read, and the message says to read the JSON first but not how:
> {noformat}
> 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
> {noformat}
> "set it with setBody" is the answer for the common case - a file the route
> knows the name of - and it does not say what to put in the setBody. In the AI
> route benchmark this exact failure produced 24 exceptions per run over five
> runs, with the model reading the message every time and never adding the
> read, because the message names the mechanism and not the form.
> The two hints now carry the rule and both forms:
> {noformat}
> The jsonpath expression got no message body to evaluate (the body is null): a
> route reached with direct: has
> the body of its caller, so when the caller has none, read the data first -
> setBody with
> constant: resource:file:data.json for a known file, or poll:, pollEnrich or a
> from: consumer for one that is not
> {noformat}
> Same wording in {{JqExpression}}. Related to CAMEL-24838, which added the
> original hint.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)