k-krawczyk opened a new pull request, #30766: URL: https://github.com/apache/camel/pull/30766
Fixes CAMEL-26553, found in the review of CAMEL-26512 (#29108). spring-ai-embeddings and langchain4j-embeddings embedded only a body, or List element, from a fixed list of types. Everything else failed, including values Camel converts to real text: a char[], a Netty ByteBuf (netty-http with disableStreamCache=true), a custom type with its own converter to String, and a List with such an element. spring-ai embedded these before CAMEL-26512. Both producers now use the rule from camel-ibm-watsonx-ai (CAMEL-26521) and camel-alibaba-kms (CAMEL-27035). The value is read with the type converter, and it is rejected only when all three hold: - BodyFacts.kindOf(value) is not PAYLOAD, - it is not a UUID, URI, URL, java.time value, Date or ByteArrayOutputStream, - the text equals value.toString(), which is what the ToStringTypeConverter fallback gives. A converter lookup cannot tell a real converter from that fallback, because CoreTypeConverterRegistry caches the fallback for the pair of types before its canPromote check. That is why the rule compares the text instead. ByteArrayOutputStream, which camel-tika parse puts in the body, is named explicitly: its toString() decodes the same bytes the converter reads, so the comparison alone would reject it. Behaviour after the change: - char[], ByteBuffer, ByteBuf, ByteArrayOutputStream, a custom converter, a UUID, and a List with such elements are embedded as their text. - A Map, a POJO, a Set and an array of texts still fail without calling the model. The message now says to marshal the value first, or to use convertBodyTo(String.class) when its toString() is the text. - In spring-ai a number is embedded as its text again, as before CAMEL-26512 and as in watsonx. Also updated: the component docs and @BodyTypes descriptions (with their catalog copies), and the spring-ai-embeddings entry in the 4.24 upgrade guide, which named convertBodyTo(String.class) as the workaround for these bodies. Tests: SpringAiEmbeddingsComponentTest and LangChain4jEmbeddingsBodyTest cover char[], ByteBuffer, ByteArrayOutputStream, a custom type with a converter registered on the context, Lists with char[] and ByteArrayOutputStream elements, and a UUID. Map and POJO bodies still fail and the model is not called. Known follow-ups, not in this PR: - camel-langchain4j-embeddingstore (auto-embedding on ADD/SEARCH) and camel-langchain4j-ingest still use the fixed list, and their 4.24 upgrade-guide entries describe it. - The rule is now private in four components. A shared helper in camel-support could replace the copies. _Reported by Claude Code on behalf of Karol Krawczyk_ -- 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]
