davsclaus opened a new pull request, #29033:
URL: https://github.com/apache/camel/pull/29033

   Fixes [CAMEL-26212](https://issues.apache.org/jira/browse/CAMEL-26212).
   
   ## A List body with a binary mimeType fails with "argument type mismatch"
   
   **What was wrong:** for a binary `mimeType`, `AiResourceExecutor` reads the 
reply with `getBody(byte[].class)`. A `List` body makes the type converter 
throw a `TypeConversionException`. It escaped the `conversionError` path and 
came back as `Error reading resource 'camel:///list.bin': Error during type 
conversion from type: java.lang.String to the required type: byte[] due to 
java.lang.IllegalArgumentException: argument type mismatch`. That message does 
not say which type was expected or which mimeType was declared.
   
   **What changed:** `convertBody` catches the `TypeConversionException` for 
both the `String` (textual mimeType) and the `byte[]` (binary mimeType) 
conversion and returns the same conversion error as for a null result: 
`Resource '...' produced a body that cannot be converted to byte[] (declared 
mimeType is ...)`. The `TypeConversionException` is kept as the cause of the 
`IllegalStateException`, so the server log still shows the converter detail.
   
   The MCP server bridge already maps every `ExecutionError` to a generic read 
error for the client and logs the message at WARN, so clients see no change; 
only the log message gets clearer.
   
   ## Tests
   
   `AiResourceExecutorTest`:
   - `testListBodyWithBinaryMimeTypeIsAConversionError`: a `List` body with 
`application/octet-stream`. It failed before the fix (the generic "argument 
type mismatch" message) and passes now.
   - `testMapBodyWithBinaryMimeTypeIsAConversionError`: a `Map` body with 
`application/octet-stream`. A `Map` converts to null rather than throwing, so 
this already passed; it covers the null-result path, which had no test.
   
   Module suite: 30 tests, 0 failures (`mvn clean install -Psourcecheck`).
   
   ## Not changed
   
   - The `@BodyTypes` reply description already says a Map, a List or another 
object "fails as a blob: marshal it first", which stays true. No doc or 
generated file changes.
   - No upgrade-guide entry: the result was an error before and is an error 
now, only with a clearer message.
   
   _Claude Code on behalf of Claus Ibsen (davsclaus)_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
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]

Reply via email to