Karol Krawczyk created CAMEL-27093:
--------------------------------------
Summary: 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
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)