davsclaus opened a new pull request, #27300: URL: https://github.com/apache/camel/pull/27300
[CAMEL-25285](https://issues.apache.org/jira/browse/CAMEL-25285) `unmarshal` with a null message body failed in the type converter: the default `DataFormat.unmarshal(Exchange, Object)` does a mandatory conversion to `InputStream`, and the message was ``` No type converter available to convert from type: null to the required type: java.io.InputStream ``` That names neither the data format nor the cause. Found in the local-model benchmark: the model replaced the step that loads a file into the body with `unmarshal`, got this message, didn't recognize the cause, and reported the change as done. ### What changes - **`UnmarshalProcessor`**: when the body (or the `variableSend` variable) is null and the conversion fails on it, the exception says so: ``` Cannot unmarshal using jackson: the message body is null, so there is nothing to unmarshal. Set the message body first, or set allowNullBody=true to skip a null body. ``` - The type stays `NoTypeConversionAvailableException`, so an `onException` for it still matches. - The converter's exception is kept as the cause. - A data format that handles a null body itself is unaffected: only that failure is reworded. - **`NoTypeConversionAvailableException`** (camel-api): - A null value now adds `(the value is null)`. - A class without a canonical name (an anonymous class) shows its binary name. Before, it also printed `from type: null`, which looked like a null value. `TypeConversionException` already did this. - A new constructor `(String message, Object value, Class<?> type)` takes the message first, so existing `(value, type, null)` calls of the `(value, type, Throwable)` constructor don't become ambiguous. `marshal` on a null body never fails (Jackson gives the text `null`); that's CAMEL-25284, `allowNullBody` on marshal. ### Tests - `UnmarshalProcessorTest`: null body, null `variableSend` variable, and a body that can't be converted keeps the converter's message. - `NoTypeConversionAvailableExceptionMessageTest` (new): null value, named class, anonymous class (both `createMessage` variants), the new constructor. - camel-core tests matching `*Marshal*`, `*DataFormat*`, `*TypeConver*`, `*Converter*`, `*InvalidPayload*`, `*MandatoryBody*`: 323 tests in 57 classes pass. - Checked with `camel run` on the installed snapshot: json (Jackson) and csv both give the new message. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01STT6whBgK1AqsSsUKrnE8m -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
