[ 
https://issues.apache.org/jira/browse/CAMEL-25455?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Work on CAMEL-25455 started by shashank.
----------------------------------------
> camel-wasm - the wasm predicate never matches a Boolean, String or byte[] 
> result
> --------------------------------------------------------------------------------
>
>                 Key: CAMEL-25455
>                 URL: https://issues.apache.org/jira/browse/CAMEL-25455
>             Project: Camel
>          Issue Type: Bug
>            Reporter: shashank
>            Assignee: shashank
>            Priority: Minor
>
> {{WasmExpression.matches()}} (camel-wasm, main e1bdb2f124b4, line 142) only 
> returns true for a Jackson {{BooleanNode}} or a non-empty 
> {{java.util.Collection}}; every other result is false. The result type of the 
> {{wasm}} language defaults to {{byte[]}} (the raw bytes the function 
> returns), so as a predicate it never matches:
> {code:java}
> from("direct:in")
>     .filter().wasm("is_valid", "classpath:functions.wasm")   // byte[] 
> result: never passes
>     .to("direct:valid");
> {code}
> With {{resultType}} {{Boolean}} the expression evaluates to {{Boolean.TRUE}} 
> and {{matches()}} still returns false; the same with {{String}}. A predicate 
> only works with {{resultType=com.fasterxml.jackson.databind.JsonNode}} plus a 
> Jackson type converter on the classpath (camel-jackson is not a dependency of 
> camel-wasm), which is not documented. The checks date from the original 
> contribution (CAMEL-20336) and match camel-jq, whose result is always a 
> {{JsonNode}}.
> h3. Reproduction
> {{filter().wasm("transform", "functions.wasm", resultType)}} with the 
> {{functions.wasm}} module of the camel-wasm tests ({{transform}} upper-cases 
> the body) and bodies {{false}}, empty and {{true}}: on main no message passes 
> for {{byte[]}}, {{String}} or {{Boolean}} ({{mock://result Received message 
> count. Expected: <1> but was: <0>}}, two runs). A survey probe with a guest 
> that returns {{true}}: {{evaluate}} -> {{true}} ({{java.lang.Boolean}}), 
> {{matches}} -> {{false}}; the Filter EIP passed 0 of 1.
> h3. Proposed fix
> Evaluate the result with {{ObjectHelper.evaluateValuePredicate}} like 
> {{ExpressionSupport}}, camel-bean and camel-quickjs ({{Boolean}} as is, 
> {{true}}/{{false}} text in any case, empty is false, other non-null values 
> true), converting a {{byte[]}} result to a {{String}} with the exchange 
> charset first. Keep the JSON case as it is: a {{JsonNode}} only matches when 
> it is the boolean {{true}}. Docs: a predicate section in the language page; a 
> short upgrade-guide note since predicates that never matched can now match.
> Affected: since 4.5 (the wasm language), main included.
> Duplicate check (2026-10-07): no camel-wasm JIRA component; text search 
> "wasm" finds CAMEL-20336, CAMEL-21569, CAMEL-24059 (all resolved, none about 
> predicates). GitHub pull requests "wasm": none open on this.
> _Filed with Claude Code on behalf of allthingssecurity._



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to