oscerd opened a new pull request, #29214: URL: https://github.com/apache/camel/pull/29214
Fixes the camel-milvus, camel-neo4j, camel-qdrant and camel-weaviate part of [CAMEL-26300](https://issues.apache.org/jira/browse/CAMEL-26300), found by the runtime tests of the body types of the data type transformers (CAMEL-25928). CAMEL-26300 is fixed with one PR per component. Fixes the camel-milvus, camel-neo4j, camel-qdrant and camel-weaviate item of CAMEL-26300: their embeddings transformers failed with a bare `NullPointerException` without the embedding header, and `neo4j:rag` cast the text of each row to `String`. ## 1. The embeddings transformers without the embedding header **Was:** `milvus:embeddings`, `neo4j:embeddings`, `qdrant:embeddings` and `weaviate:embeddings` failed with a bare `NullPointerException` when the message did not have the `CamelLangChain4jEmbeddingsVector` header. **Now:** they fail with an `IllegalArgumentException` that names the header, with the same message and exception type as `pgvector:embeddings`: "Missing embedding vector header 'CamelLangChain4jEmbeddingsVector'. Ensure the langchain4j-embeddings component is called before this transformer." The check runs first, so it is the same for every action of `milvus:embeddings` and `weaviate:embeddings`. ## 2. neo4j:rag with a text that is not a String **Was:** `neo4j:rag` cast the `text` value of each row to `String`. A value of another type, such as a number, failed with a `ClassCastException`, and a `null` value gave a `null` element in the result. **Now:** a value of another type is converted to a `String` with the type converters of the CamelContext (a number gives its digits, a `byte[]` its text), and a `null` value gives an empty String, as a row without text already did. A `String` is kept as it is. ## Tests - `MilvusEmbeddingsDataTypeTransformerTest`: a new test checks INSERT and UPSERT without the embedding header. - `Neo4jEmbeddingDataTypeTransformerTest`, `QdrantEmbeddingsDataTypeTransformerTest` and `WeaviateEmbeddingsDataTypeTransformerTest` (CREATE, UPDATE_BY_ID and QUERY): the existing checks for a missing embedding header now expect the `IllegalArgumentException` that names the header, instead of the `NullPointerException`. - `Neo4jReverseEmbeddingsDataTypeTransformerTest`: a new test gives rows whose text is a `Long`, a `Double`, a `byte[]`, `null` or a `String`, and checks that the result is `"42"`, `"0.5"`, `"hello"`, `""` and `"hello"`. - Revert check, with the five transformers reverted: 5 of the 5 new or changed tests fail. Four expect the `IllegalArgumentException` and get the old `NullPointerException`; the `neo4j:rag` test gets the old `ClassCastException` (a `Long` cast to `String`). The 7 other transformer tests of these modules, which are unchanged, pass both ways. - Module totals, 0 failures: camel-milvus 8 tests, camel-neo4j 26, camel-qdrant 17, camel-weaviate 26. ## Docs and generated files - The body types of `neo4j:rag` now say that the text is converted to `String` and that a row without text gives an empty String (`neo4j-rag.json` and its catalog copy). The RAG section of `neo4j-component.adoc` (and its catalog copy) says the same. - The body types of the four embeddings transformers already said that the embedding header must be set, so they are unchanged, as the `pgvector:embeddings` ones are. - An upgrade guide entry for 4.24. ## Not changed - A null body still fails with a `NullPointerException` in `milvus:embeddings`, `neo4j:embeddings` and `neo4j:rag`. Their body types say that it fails, and the issue covers only the missing header. - A `CamelLangChain4jEmbeddingsVector` header that does not convert to an `Embedding` also gets the "Missing embedding vector header" message, as in `pgvector:embeddings`. - `qdrant:rag` reads the `text_segment` payload with `getStringValue()`, so a payload of another type gives an empty String rather than failing. The issue does not mention it, so it is left as it is. Main only, as the other fixes of the CAMEL-24961 follow-ups. _Claude Code on behalf of Andrea Cosentino (oscerd)_ 🤖 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]
