Repository navigation
CAMEL-26386: camel-yaml-dsl-validator - Body type checks: a field read on the List of a JSON array file, a field read after a marshal of an unknown body, a variableSend of a header, and a setBody that emptied the body - #28636
Conversation
…d on the List of a JSON array file, a field read after a marshal of an unknown body, a variableSend of a header, and a setBody that emptied the body - The AI tools read which JSON files a resource: of the routes loads are arrays (ProjectFacts.jsonArrays), and the validator reports a Simple field read on that List when the file is written, with the jsonpath advice of the runtime hint. Groovy is left alone. - A field read after a marshal of a body that is not known says to read the field before the marshal first, and to unmarshal only when the body was text that was meant to be parsed. - A variableSend of a variable that no step sets, where the route sets a header of that name, is reported. - The runtime hint for a null or empty body names the setBody or transform that emptied it, from the message history. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01STT6whBgK1AqsSsUKrnE8m Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
gnodet
left a comment
There was a problem hiding this comment.
Well-structured PR adding four new validator checks motivated by real benchmark failures. The logic is sound, the test coverage is thorough, and the Walk record propagation is correctly applied at all three construction sites. Two minor nits.
Nit 1 — Dead early-exit branch in checkVariableSendOfAHeader
if (text.contains("\"process\"") || text.contains("\"bean\"") || text.contains("\"script\"")
|| text.contains("setVariable(") || text.contains("\"setVariables\"")) {All the other checks quote the JSON key form ("\"process\"", "\"bean\"", "\"setVariables\""), because text comes from target.toString() on a JsonNode — which produces JSON. A JSON key appears as "setVariable", never as setVariable(. The parenthesised form will never match, so this branch is dead. Should be text.contains("\"setVariable\"").
Nit 2 — listRead(value) evaluated twice
} else if (body instanceof Parsed parsed && parsed.list()
&& (listRead(value) != null || templateRead(name, value, LIST_PROPERTIES) != null)) {
String read = listRead(value);
w.errors().add(listError(here, w.routeId(),
read != null ? read : templateRead(name, value, LIST_PROPERTIES), parsed));listRead(value) is called once in the condition and again in the body. Cache it before the condition:
String listRead = listRead(value);
} else if (body instanceof Parsed parsed && parsed.list()
&& (listRead != null || templateRead(name, value, LIST_PROPERTIES) != null)) {
w.errors().add(listError(here, w.routeId(),
listRead != null ? listRead : templateRead(name, value, LIST_PROPERTIES), parsed));|
🧪 CI tested the following changed modules:
🔁 1 test passed only after a retry on JDK 21 (1 retried attempt) Recovered flaky tests on JDK 21 (1)
🔬 Scalpel shadow comparison — Scalpel: 575 of 708 tested, 26 compile-only — current: 576 all testedMaveniverse Scalpel detected 575 affected modules (current approach: 576). Skip-tests mode would test 575 modules (4 direct + 572 downstream), skip tests for 26 (generated code, meta-modules) Modules only in current approach (1)
Modules Scalpel would test (575)
Modules with tests skipped (26)
💡 Manual integration tests recommended:
Build reactor — dependencies compiled but only changed modules were tested (4 modules, 30.1s total)Total reactor time: 30.1s
Top 20 slowest modules:
|
https://issues.apache.org/jira/browse/CAMEL-26386
Four findings from the local-model benchmark (r23), after the body type checks of CAMEL-25928 (#28500):
setBody resource:file:orders.jsonandunmarshal: json, the model read${body.orderId}. The runtime hint came only after the first reload, so 4 runs that ended right still failed on the errors of their first version. The AI tools now read which JSON files of the project aresource:loads are arrays (ProjectFacts.jsonArrays), and the validator reports a Simple field read on that List at write time, with the jsonpath advice of the runtime hint. Groovy is left alone (body.orderIdof a List is the List of the orderIds there).direct:route a wire tap sends the order Map to, the advice "unmarshal: json is the step, not marshal" made the model unmarshal the Map, which failed at runtime. The advice now says first to read the field before the marshal.variableSendof a header (ai step 1): the model set a headerpromptand sentvariableSend: prompt, so the chat model got an empty request. This is reported when the route sets the header and nothing sets the variable (no bean, processor or script either).setBodyortransformthat emptied it, from the message history, instead of "read the data first".Tests: camel-yaml-dsl-validator (322), all camel-jbang-core AI tool tests (756), BodyFactsTest (11), green.
🤖 Generated with Claude Code
https://claude.ai/code/session_01STT6whBgK1AqsSsUKrnE8m