[
https://issues.apache.org/jira/browse/CAMEL-27093?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18151578#comment-18151578
]
Claus Ibsen commented on CAMEL-27093:
-------------------------------------
[~ravismash] thanks, please go ahead and open a PR with your fix.
Note that https://github.com/apache/camel/pull/30869 (CAMEL-27570 to
CAMEL-27574) rewrites a large part of camel-ibm-watsonx-ai, including
AbstractWatsonxAiHandler where getInputs is. It does not address this ticket,
so your fix is still needed, but the two will likely conflict. Opening your PR
soon makes it easier to coordinate; if #30869 is merged first, rebase on main.
_Claude Code on behalf of davsclaus_
> 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)