[ 
https://issues.apache.org/jira/browse/CAMEL-27093?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18150636#comment-18150636
 ] 

Ravi Prakash Meena commented on CAMEL-27093:
--------------------------------------------

Hi, I'd like to work on this. I have a fix ready: {{getInputs}} checks each 
element of the List (body and the {{CamelIbmWatsonxAiInputs}} header) like 
{{toChatMessages}} does. A String or a toString-text value (UUID, URI, date) is 
kept, anything else fails with its index and class before a request is sent. 
Tests are in {{WatsonxAiMessageBodyTest}}.

_Claude Code on behalf of Ravi_

> camel-ibm-watsonx-ai - the List body of embedding and rerank is cast to 
> List<String> without checking its elements
> ------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-27093
>                 URL: https://issues.apache.org/jira/browse/CAMEL-27093
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-ai
>            Reporter: Karol Krawczyk
>            Priority: Minor
>
> Raised in the review of https://github.com/apache/camel/pull/30256 
> (CAMEL-26521).
> {{AbstractWatsonxAiHandler.getInputs}}, which embedding and rerank use, casts 
> a List body to {{List<String>}} without looking at the elements:
> {code:java}
> if (body instanceof List) {
>     inputs = (List<String>) body;
> }
> {code}
> An element that is not a String reaches the watsonx.ai SDK, where it fails 
> with a ClassCastException or is serialized as something the model did not ask 
> for, instead of a message that says what the body must be. CAMEL-26222 closed 
> the same gap for the chat messages: {{toChatMessages}} checks each element 
> and fails with an IllegalArgumentException that names the class of the 
> offending element.
> Proposed: check the elements of the List body of embedding and rerank the 
> same way. A String is an input text; any other element fails with a message 
> that names its class and its index. A value whose text is its toString(), 
> such as a UUID or a URI, is read as text, as a single body is since 
> CAMEL-26521.
> _Reported by Claude Code on behalf of Karol Krawczyk_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to