[
https://issues.apache.org/jira/browse/CAMEL-25749?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18128378#comment-18128378
]
Claus Ibsen commented on CAMEL-25749:
-------------------------------------
h3. Design (2026-10-18), for review before code
*The facts are there.* {{MessageHistory.getBodyType()}} is the class of the
body when each node was reached, before the node ran (every message history
factory captures it), and {{LoggerHelper.getLineNumberLoggerName(node)}} gives
the node's source location ({{invoices.yaml:30}}), as the error registry prints
it since CAMEL-24972. So, for a failure at node n whose body has type T:
* *the step that set it* is the last node k before n whose recorded type
differs from T: it ran on another type and left T. When every recorded type is
T, the consumer set it ("unchanged since from: file:inbox");
* with message history off, only T is known, and the sentence leaves the step
out.
*The helper (camel-support).* One small public class, name open
({{BodyFacts}}?), two methods:
* {{describe(Exchange)}}: "the body is a GenericFile (the file as read),
unchanged since from: file:inbox (invoices.yaml:30)". The body in plain words:
text, bytes, a cached stream, the file as read, parsed data (a Map, a List), an
object of a named class, an iterator (no size), null.
* {{fix(Exchange, Need)}}, where the need is what the failing step wanted:
fields (unmarshal with the data format of the payload), text or a stream
(marshal: json, convertBodyTo String), a body at all (setBody, pollEnrich).
No camel-api change: the callers pass the sentence to the hint argument
{{InvalidPayloadException}} already has, and to the message argument of
{{NoTypeConversionAvailableException}}.
*Callers, in order.*
# The sentences that exist move onto it, keeping their tests, so the wording
becomes one: camel-http producer (CAMEL-25309), platform-http reply and file
write (CAMEL-25751, PR 28048), Groovy on text (CAMEL-25330), unmarshal on null
(CAMEL-25285), jsonpath/jq on null (CAMEL-24838), the missing Map key
(CAMEL-25322).
# Then the failures that have none today, seen in the benchmark:
{{$\{body.qty\}}} on the stream cache of an HTTP request ("Method with name:
qty not found on bean: ...ByteArrayInputStreamCache"), {{$\{body\[status\]\}}}
on the file consumer's GenericFile ("Key: status not found in bean:
GenericFile[...]"), {{$\{body.size()\}}} on sql's StreamList ("Method with
name: size() not found on bean: ...ResultSetIterator").
*Kept from 2026-09-20.* A body sentence only where the failure is about the
body; an error about a header or a property gets none.
*Measure.* Runtime sentences show as recoveries, not as fewer collisions: the
model hits the error, reads the sentence, and the step still passes (the
CAMEL-25309 sentence: 5 of 6 runs of contracts-openapi-client recovered in
r17). Count, per series, the runs that hit a body type collision and the ones
of those that still passed.
*Build note.* The helper is in camel-support and the callers are in camel-http,
camel-groovy, camel-jsonpath, camel-jq, camel-bean and camel-core, so it needs
an install of camel-support to test the callers; not done today, since a
running Camel CLI holds the camel-support jar of ~/.m2.
_Claude Code on behalf of davsclaus_
> camel-support - one helper for errors about the message body: what the body
> is, which step set it, and the step that fixes it
> -----------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-25749
> URL: https://issues.apache.org/jira/browse/CAMEL-25749
> Project: Camel
> Issue Type: Improvement
> Components: camel-bean, camel-groovy, camel-jq, camel-jsonpath,
> camel-support
> Reporter: Claus Ibsen
> Priority: Major
> Fix For: 4.24.0
>
>
> Step 1 of the design note of 2026-10-05 on CAMEL-24844 (runtime errors).
> When a step fails because of the Java type of the body, the reader of the
> error (a person, or a model in a dev loop) needs three facts: what the body
> is, which step made it so, and the step that fixes it. For example:
> bq. {{$\{body\[amount\]\}}} failed: the body is a GenericFile (the file as
> read), unchanged since {{from: file:inbox}} (invoices.yaml:30). Unmarshal it
> first ({{unmarshal: json}}) to read its fields.
> The facts are recorded already: the message history has the body type of
> every step ({{MessageHistory.getBodyType()}}, 4.23) and the source location
> of each step (CAMEL-24972). What is missing is one place that says them.
> Today each failure writes its own partial hint, in its own words:
> * camel-groovy {{GroovyExpression}}: a property read on a body that is still
> text (CAMEL-25330)
> * camel-support {{UnmarshalProcessor}}: unmarshal on a null body (CAMEL-25285)
> * camel-jsonpath {{JsonPathEngine}} and camel-jq {{JqExpression}}: a null
> body (CAMEL-24838)
> * camel-bean {{BeanExpression}}: a missing Map key lists the keys of the Map
> (CAMEL-25322)
> * {{InvalidPayloadException}} and {{NoTypeConversionAvailableException}} name
> the type of the body, and take a hint from a caller that knows more
> h3. Proposal
> * One helper in camel-support that builds the sentence from the exchange:
> ** the body in plain words: text, bytes, a cached stream, the file as read,
> parsed data (a Map or a List), an object of a named class, or null;
> ** the step that set it, from the message history: route, node and source
> location;
> ** the step that fixes it: unmarshal with the data format of the payload,
> convertBodyTo String, or setBody.
> * With message history off, it still names the body; only the step that set
> it is left out.
> * The hints above move onto it, so the wording is the same everywhere.
> * Only failures about the body use it: an expression that reads the body
> (simple and bean OGNL, Groovy, jsonpath, jq), a conversion of the body,
> {{InvalidPayloadException}}. An error about a header or an exchange property
> gets no body sentence, as agreed on CAMEL-24844 on 2026-09-20.
> h3. Measure
> The body type collisions per series of the local-model benchmark (19 of 156
> attempts in the round-2 series), before and after.
> h3. Not in scope
> The static checks of the validator, the observed types (step 2, CAMEL-25750),
> the catalog metadata (CAMEL-24961).
> _Filed by Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v8.20.10#820010)