This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 63c0ee3e7039 CAMEL-27098: camel-pinecone - the pinecone:embeddings 
transformer leaves the index name header unset (#30452)
63c0ee3e7039 is described below

commit 63c0ee3e7039ad6afd630a6c20b7c09a56fbe847
Author: Pratik <[email protected]>
AuthorDate: Sat Nov 21 12:18:28 2026 -0800

    CAMEL-27098: camel-pinecone - the pinecone:embeddings transformer leaves 
the index name header unset (#30452)
    
    PineconeEmbeddingsDataTypeTransformer defaulted the CamelPineconeIndexName 
header to "embeddings" and always wrote it back. The Pinecone producer takes 
the header over the indexName option of the endpoint, so every index action 
worked on the "embeddings" index instead of the configured one.
    
    The transformer no longer sets the index name header: a header the route 
set is kept, and without one the producer uses the indexName option of its 
endpoint. The component documentation and the 4.24 upgrade guide are updated; 
routes that relied on the "embeddings" index must set the header or 
indexName=embeddings.
---
 .../camel/catalog/docs/pinecone-component.adoc     |  2 +-
 .../src/main/docs/pinecone-component.adoc          |  2 +-
 .../PineconeEmbeddingsDataTypeTransformer.java     |  6 +++---
 .../pinecone/PineconeVectorDbProducerTest.java     |  4 ++--
 .../PineconeEmbeddingsDataTypeTransformerTest.java | 24 ++++++++++++++++++++++
 .../ROOT/pages/camel-4x-upgrade-guide-4_24.adoc    | 11 ++++++++++
 6 files changed, 42 insertions(+), 7 deletions(-)

diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/pinecone-component.adoc
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/pinecone-component.adoc
index ae76560e4878..796cacfefb6b 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/pinecone-component.adoc
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/pinecone-component.adoc
@@ -78,6 +78,6 @@ The vector of UPSERT, UPDATE and QUERY is the message body: a 
List of numbers, s
 
 UPSERT stores the `CamelPineconeMetadata` header, a 
`com.google.protobuf.Struct`, as the metadata of the vector, and UPDATE sets 
the fields of that header in the metadata of the vector.
 
-The `pinecone:embeddings` data type transformer turns the embedding of the 
`CamelLangChain4jEmbeddingsVector` header, which the langchain4j-embeddings 
component sets, into the vector of the message body, and fails when the header 
is missing. It puts the text of a LangChain4j `TextSegment` or `String` body in 
the `text_segment` field of the `CamelPineconeMetadata` header, and keeps the 
other fields of that header. Without the `CamelPineconeIndexName` and 
`CamelPineconeIndexId` headers, it [...]
+The `pinecone:embeddings` data type transformer turns the embedding of the 
`CamelLangChain4jEmbeddingsVector` header, which the langchain4j-embeddings 
component sets, into the vector of the message body, and fails when the header 
is missing. It puts the text of a LangChain4j `TextSegment` or `String` body in 
the `text_segment` field of the `CamelPineconeMetadata` header, and keeps the 
other fields of that header. Without the `CamelPineconeIndexId` header, it sets 
it to a random UUID. It  [...]
 
 The `pinecone:rag` data type transformer turns the result of a QUERY or 
QUERY_BY_ID into the List of the texts of its matches, read from their 
`text_segment` metadata, which the query returns when the 
`CamelPineconeQueryIncludeMetadata` header is `true`.
diff --git 
a/components/camel-ai/camel-pinecone/src/main/docs/pinecone-component.adoc 
b/components/camel-ai/camel-pinecone/src/main/docs/pinecone-component.adoc
index ae76560e4878..796cacfefb6b 100644
--- a/components/camel-ai/camel-pinecone/src/main/docs/pinecone-component.adoc
+++ b/components/camel-ai/camel-pinecone/src/main/docs/pinecone-component.adoc
@@ -78,6 +78,6 @@ The vector of UPSERT, UPDATE and QUERY is the message body: a 
List of numbers, s
 
 UPSERT stores the `CamelPineconeMetadata` header, a 
`com.google.protobuf.Struct`, as the metadata of the vector, and UPDATE sets 
the fields of that header in the metadata of the vector.
 
-The `pinecone:embeddings` data type transformer turns the embedding of the 
`CamelLangChain4jEmbeddingsVector` header, which the langchain4j-embeddings 
component sets, into the vector of the message body, and fails when the header 
is missing. It puts the text of a LangChain4j `TextSegment` or `String` body in 
the `text_segment` field of the `CamelPineconeMetadata` header, and keeps the 
other fields of that header. Without the `CamelPineconeIndexName` and 
`CamelPineconeIndexId` headers, it [...]
+The `pinecone:embeddings` data type transformer turns the embedding of the 
`CamelLangChain4jEmbeddingsVector` header, which the langchain4j-embeddings 
component sets, into the vector of the message body, and fails when the header 
is missing. It puts the text of a LangChain4j `TextSegment` or `String` body in 
the `text_segment` field of the `CamelPineconeMetadata` header, and keeps the 
other fields of that header. Without the `CamelPineconeIndexId` header, it sets 
it to a random UUID. It  [...]
 
 The `pinecone:rag` data type transformer turns the result of a QUERY or 
QUERY_BY_ID into the List of the texts of its matches, read from their 
`text_segment` metadata, which the query returns when the 
`CamelPineconeQueryIncludeMetadata` header is `true`.
diff --git 
a/components/camel-ai/camel-pinecone/src/main/java/org/apache/camel/component/pinecone/transform/PineconeEmbeddingsDataTypeTransformer.java
 
b/components/camel-ai/camel-pinecone/src/main/java/org/apache/camel/component/pinecone/transform/PineconeEmbeddingsDataTypeTransformer.java
index 4d0c6075a4e4..898d65e2fb5a 100644
--- 
a/components/camel-ai/camel-pinecone/src/main/java/org/apache/camel/component/pinecone/transform/PineconeEmbeddingsDataTypeTransformer.java
+++ 
b/components/camel-ai/camel-pinecone/src/main/java/org/apache/camel/component/pinecone/transform/PineconeEmbeddingsDataTypeTransformer.java
@@ -63,9 +63,9 @@ public class PineconeEmbeddingsDataTypeTransformer extends 
Transformer {
         }
         TextSegment text = message.getBody(TextSegment.class);
         String indexId = message.getHeader(PineconeVectorDbHeaders.INDEX_ID, 
UUID.randomUUID(), String.class);
-        String indexName = 
message.getHeader(PineconeVectorDbHeaders.INDEX_NAME, "embeddings", 
String.class);
-
-        message.setHeader(PineconeVectorDbHeaders.INDEX_NAME, indexName);
+        // the index name is left unset when the route does not set it, so 
that the producer uses the indexName
+        // of its endpoint; a default here would override the endpoint option, 
as the producer takes the
+        // header over the option
         message.setHeader(PineconeVectorDbHeaders.INDEX_ID, indexId);
         if (text != null) {
             // added to the metadata the caller may have set, which is kept
diff --git 
a/components/camel-ai/camel-pinecone/src/test/java/org/apache/camel/component/pinecone/PineconeVectorDbProducerTest.java
 
b/components/camel-ai/camel-pinecone/src/test/java/org/apache/camel/component/pinecone/PineconeVectorDbProducerTest.java
index 8213f1a4766d..9c7c7f1efab1 100644
--- 
a/components/camel-ai/camel-pinecone/src/test/java/org/apache/camel/component/pinecone/PineconeVectorDbProducerTest.java
+++ 
b/components/camel-ai/camel-pinecone/src/test/java/org/apache/camel/component/pinecone/PineconeVectorDbProducerTest.java
@@ -289,11 +289,11 @@ class PineconeVectorDbProducerTest extends 
CamelTestSupport {
         // CAMEL-26300: the pinecone:embeddings transformer puts the text in 
the text_segment metadata that UPSERT stores,
         // which the pinecone:rag transformer reads from the matches of a 
QUERY. Before, the text was not stored, and the
         // match of the vector gave an empty String.
+        // CAMEL-27098: no CamelPineconeIndexName header is set, as the 
transformer leaves it unset and the UPSERT
+        // uses the indexName of the endpoint
         Exchange upsert = fluentTemplate.to("direct:embeddings")
                 
.withHeader(CamelLangchain4jAttributes.CAMEL_LANGCHAIN4J_EMBEDDING_VECTOR,
                         new Embedding(new float[] { 0.1f, 0.2f, 0.3f }))
-                // the index of the endpoint, as the transformer gives the 
embeddings index without this header
-                .withHeader(PineconeVectorDbHeaders.INDEX_NAME, indexName)
                 .withHeader(PineconeVectorDbHeaders.INDEX_ID, "vector-1")
                 .withBody(TextSegment.from("the source passage"))
                 .request(Exchange.class);
diff --git 
a/components/camel-ai/camel-pinecone/src/test/java/org/apache/camel/component/pinecone/transform/PineconeEmbeddingsDataTypeTransformerTest.java
 
b/components/camel-ai/camel-pinecone/src/test/java/org/apache/camel/component/pinecone/transform/PineconeEmbeddingsDataTypeTransformerTest.java
index da84b739d659..bf12705f5fcd 100644
--- 
a/components/camel-ai/camel-pinecone/src/test/java/org/apache/camel/component/pinecone/transform/PineconeEmbeddingsDataTypeTransformerTest.java
+++ 
b/components/camel-ai/camel-pinecone/src/test/java/org/apache/camel/component/pinecone/transform/PineconeEmbeddingsDataTypeTransformerTest.java
@@ -105,6 +105,30 @@ class PineconeEmbeddingsDataTypeTransformerTest {
         assertEquals("hello", 
metadata.getFieldsOrThrow("text_segment").getStringValue());
     }
 
+    @Test
+    void theIndexNameHeaderIsLeftUnsetWithoutTheHeader() throws Exception {
+        // CAMEL-27098: the transformer leaves CamelPineconeIndexName unset, 
so that the producer uses the indexName
+        // of its endpoint; before, it set the header to embeddings, which the 
producer takes over the endpoint
+        Message message = transform(TextSegment.from("hello"), new 
Embedding(new float[] { 0.1f, 0.2f, 0.3f }));
+        assertNull(message.getHeader(PineconeVectorDbHeaders.INDEX_NAME, 
String.class));
+        // the CamelPineconeIndexId header still gets its random UUID
+        assertNotNull(message.getHeader(PineconeVectorDbHeaders.INDEX_ID, 
String.class));
+    }
+
+    @Test
+    void theIndexNameHeaderIsKept() throws Exception {
+        // CAMEL-27098: a CamelPineconeIndexName header the route set is kept, 
and the producer takes it over
+        // the indexName of its endpoint
+        Exchange exchange = new DefaultExchange(camelContext);
+        
exchange.getMessage().setHeader(CamelLangchain4jAttributes.CAMEL_LANGCHAIN4J_EMBEDDING_VECTOR,
+                new Embedding(new float[] { 0.1f, 0.2f, 0.3f }));
+        exchange.getMessage().setHeader(PineconeVectorDbHeaders.INDEX_NAME, 
"my-index");
+        exchange.getMessage().setBody(TextSegment.from("hello"));
+        transformer.transform(exchange.getMessage(), DataType.ANY, 
DataType.ANY);
+
+        assertEquals("my-index", 
exchange.getMessage().getHeader(PineconeVectorDbHeaders.INDEX_NAME, 
String.class));
+    }
+
     @Test
     void aMessageWithoutTheEmbeddingFailsWithAClearMessage() {
         // CAMEL-26300: an IllegalArgumentException that names the missing 
header, as pgvector:embeddings gives, instead of
diff --git 
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc 
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
index e95fd3c6f009..8ab48d5b6d8d 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
@@ -10899,3 +10899,14 @@ response or the request, and log it at DEBUG level. 
Before, camel-netty-http fai
 request, the other consumers passed the name on to the servlet container, and 
camel-http sent it, which a server may
 reject with a 400. Headers with a valid name are written as before. A route 
that needs such a value in the response or
 in the request must set it in a header with a valid name.
+
+=== camel-pinecone - the pinecone:embeddings transformer leaves the index name 
unset
+
+The `pinecone:embeddings` data type transformer no longer sets the 
`CamelPineconeIndexName` header to
+`embeddings` when the route does not set the header. The producer takes the 
header over the `indexName`
+option of its endpoint, so a route that configured `indexName` on the endpoint 
and did not set the header
+worked on the `embeddings` index instead of the configured one. The 
transformer now leaves the header
+unset, and the producer uses its `indexName` option.
+
+A route that relied on the `embeddings` index must set the 
`CamelPineconeIndexName` header to `embeddings`,
+or configure `indexName=embeddings` on the endpoint.

Reply via email to