You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "oscerd (via GitHub)" <gi...@apache.org> on 2026/09/18 10:19:32 UTC

[PR] CAMEL-24816: camel-elasticsearch/camel-opensearch - minor robustness fixes [camel]

oscerd opened a new pull request, #26590:
URL: https://github.com/apache/camel/pull/26590

   ## What
   
   Three small, shared robustness issues in `camel-elasticsearch` and `camel-opensearch`.
   
   ### 1. Scroll clear can NPE on a null scroll id
   `(Elasticsearch|Opensearch)ScrollRequestIterator.close()` built `new ClearScrollRequest.Builder().scrollId(List.of(scrollId))`. If the initial search returned no scroll id, `scrollId` is null and `List.of(null)` throws `NullPointerException` from `close()`, masking the real outcome. Now the clear-scroll is issued only when a scroll id is present.
   
   ### 2. A null index-id header clobbers a caller-supplied id
   In `(Elasticsearch|Opensearch)ActionRequestConverter`, when the body is already a pre-built `IndexRequest.Builder`/`UpdateRequest.Builder`, the converter called `.id(getHeader(PARAM_INDEX_ID))` unconditionally — overwriting a caller-set id with null when the `CamelIndexId` header was absent. Now the id is set only when the header is present. Also switched the elasticsearch document-only-mode check from reference equality (`== Boolean.TRUE`) to `Boolean.TRUE.equals(...)`.
   
   ### 3. size/from headers bleed downstream
   The producer defaults the size/from headers from the endpoint configuration when absent, but `cleanup()` removed only the index-name and wait-for-active-shards headers. A defaulted size/from therefore persisted on the exchange and leaked into a subsequent endpoint (the exact scenario the existing cleanup guards against for index-name). They are now removed in `cleanup()` too, tracked with the same `configXxx` pattern.
   
   ## Testing
   
   - New converter unit test in both components asserting a pre-built builder keeps its id when the header is absent, and that the header overrides it when present.
   - Verified both modules compile and their unit tests pass.
   
   ## Notes
   
   - Logic-only; no public API / `@UriParam` / generated-catalog change.
   - Backport candidate for `camel-4.22.x` and `camel-4.18.x`.
   
   _Generated by 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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-24816: camel-elasticsearch/camel-opensearch - minor robustness fixes [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus merged PR #26590:
URL: https://github.com/apache/camel/pull/26590


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-24816: camel-elasticsearch/camel-opensearch - minor robustness fixes [camel]

Posted by "oscerd (via GitHub)" <gi...@apache.org>.
oscerd commented on code in PR #26590:
URL: https://github.com/apache/camel/pull/26590#discussion_r4060222992


##########
components/camel-elasticsearch/src/test/java/org/apache/camel/component/es/converter/ElasticsearchActionRequestConverterTest.java:
##########
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.es.converter;
+
+import java.util.Map;
+
+import co.elastic.clients.elasticsearch.core.IndexRequest;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.es.ElasticsearchConstants;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.support.DefaultExchange;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class ElasticsearchActionRequestConverterTest {
+
+    private CamelContext context;
+
+    @BeforeEach
+    void setUp() {
+        context = new DefaultCamelContext();
+    }
+
+    @AfterEach
+    void tearDown() {
+        context.stop();
+    }
+
+    private IndexRequest.Builder<Object> preBuiltIndexBuilder() {
+        return new IndexRequest.Builder<>().index("idx").id("original").document(Map.of("k", "v"));
+    }
+
+    @Test
+    void preBuiltIndexBuilderKeepsItsIdWhenHeaderAbsent() throws Exception {
+        Exchange exchange = new DefaultExchange(context);
+
+        IndexRequest.Builder<?> result
+                = ElasticsearchActionRequestConverter.toIndexRequestBuilder(preBuiltIndexBuilder(), exchange);
+
+        // no CamelIndexId header -> the caller's id must be preserved, not overwritten with null
+        assertEquals("original", result.build().id());
+    }
+
+    @Test
+    void preBuiltIndexBuilderHeaderOverridesId() throws Exception {
+        Exchange exchange = new DefaultExchange(context);
+        exchange.getIn().setHeader(ElasticsearchConstants.PARAM_INDEX_ID, "fromHeader");
+
+        IndexRequest.Builder<?> result
+                = ElasticsearchActionRequestConverter.toIndexRequestBuilder(preBuiltIndexBuilder(), exchange);
+
+        assertEquals("fromHeader", result.build().id());
+    }
+}

Review Comment:
   Already in the branch as `preBuiltUpdateBuilderKeepsItsIdWhenHeaderAbsent`, essentially as you wrote it. The fix it pins:
   
   ```java
   String id = exchange.getIn().getHeader(ElasticsearchConstants.PARAM_INDEX_ID, String.class);
   if (id != null) {
       updateReqBuilder.id(id);
   }
   return updateReqBuilder;
   ```
   
   You are right that it can silently regress — the previous code passed the header through unconditionally, so a null cleared a caller-supplied id, and nothing would have noticed.
   
   _Claude Code on behalf of @oscerd_



##########
components/camel-opensearch/src/test/java/org/apache/camel/component/opensearch/converter/OpensearchActionRequestConverterTest.java:
##########
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.opensearch.converter;
+
+import java.util.Map;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.opensearch.OpensearchConstants;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.support.DefaultExchange;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.opensearch.client.opensearch.core.IndexRequest;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class OpensearchActionRequestConverterTest {
+
+    private CamelContext context;
+
+    @BeforeEach
+    void setUp() {
+        context = new DefaultCamelContext();
+    }
+
+    @AfterEach
+    void tearDown() {
+        context.stop();
+    }
+
+    private IndexRequest.Builder<Object> preBuiltIndexBuilder() {
+        return new IndexRequest.Builder<>().index("idx").id("original").document(Map.of("k", "v"));
+    }
+
+    @Test
+    void preBuiltIndexBuilderKeepsItsIdWhenHeaderAbsent() throws Exception {
+        Exchange exchange = new DefaultExchange(context);
+
+        IndexRequest.Builder<?> result
+                = OpensearchActionRequestConverter.toIndexRequestBuilder(preBuiltIndexBuilder(), exchange);
+
+        // no CamelOpensearchIndexId header -> the caller's id must be preserved, not overwritten with null
+        assertEquals("original", result.build().id());
+    }
+
+    @Test
+    void preBuiltIndexBuilderHeaderOverridesId() throws Exception {
+        Exchange exchange = new DefaultExchange(context);
+        exchange.getIn().setHeader(OpensearchConstants.PARAM_INDEX_ID, "fromHeader");
+
+        IndexRequest.Builder<?> result
+                = OpensearchActionRequestConverter.toIndexRequestBuilder(preBuiltIndexBuilder(), exchange);
+
+        assertEquals("fromHeader", result.build().id());
+    }
+}

Review Comment:
   The symmetric OpenSearch test is there too, same name and same shape. Both components carry `preBuiltIndexBuilderKeepsItsIdWhenHeaderAbsent`, `preBuiltIndexBuilderHeaderOverridesId` and `preBuiltUpdateBuilderKeepsItsIdWhenHeaderAbsent`, so the index and update paths are pinned in both directions — id preserved when the header is absent, overridden when it is present.
   
   _Claude Code on behalf of @oscerd_



##########
components/camel-elasticsearch/src/test/java/org/apache/camel/component/es/converter/ElasticsearchActionRequestConverterTest.java:
##########
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.es.converter;
+
+import java.util.Map;
+
+import co.elastic.clients.elasticsearch.core.IndexRequest;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.es.ElasticsearchConstants;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.support.DefaultExchange;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class ElasticsearchActionRequestConverterTest {
+
+    private CamelContext context;
+
+    @BeforeEach
+    void setUp() {
+        context = new DefaultCamelContext();
+    }
+
+    @AfterEach
+    void tearDown() {
+        context.stop();
+    }
+
+    private IndexRequest.Builder<Object> preBuiltIndexBuilder() {
+        return new IndexRequest.Builder<>().index("idx").id("original").document(Map.of("k", "v"));
+    }
+
+    @Test
+    void preBuiltIndexBuilderKeepsItsIdWhenHeaderAbsent() throws Exception {
+        Exchange exchange = new DefaultExchange(context);
+
+        IndexRequest.Builder<?> result
+                = ElasticsearchActionRequestConverter.toIndexRequestBuilder(preBuiltIndexBuilder(), exchange);
+
+        // no CamelIndexId header -> the caller's id must be preserved, not overwritten with null
+        assertEquals("original", result.build().id());
+    }
+
+    @Test
+    void preBuiltIndexBuilderHeaderOverridesId() throws Exception {
+        Exchange exchange = new DefaultExchange(context);
+        exchange.getIn().setHeader(ElasticsearchConstants.PARAM_INDEX_ID, "fromHeader");
+
+        IndexRequest.Builder<?> result
+                = ElasticsearchActionRequestConverter.toIndexRequestBuilder(preBuiltIndexBuilder(), exchange);
+
+        assertEquals("fromHeader", result.build().id());
+    }
+}

Review Comment:
   No action on this one — it reads as a placeholder ("Test comment") rather than a finding. Flagging rather than silently resolving it, in case something was meant to land here.
   
   _Claude Code on behalf of @oscerd_



-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-24816: camel-elasticsearch/camel-opensearch - minor robustness fixes [camel]

Posted by "gnodet-bot (via GitHub)" <gi...@apache.org>.
gnodet-bot commented on code in PR #26590:
URL: https://github.com/apache/camel/pull/26590#discussion_r4045884362


##########
components/camel-elasticsearch/src/test/java/org/apache/camel/component/es/converter/ElasticsearchActionRequestConverterTest.java:
##########
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.es.converter;
+
+import java.util.Map;
+
+import co.elastic.clients.elasticsearch.core.IndexRequest;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.es.ElasticsearchConstants;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.support.DefaultExchange;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class ElasticsearchActionRequestConverterTest {
+
+    private CamelContext context;
+
+    @BeforeEach
+    void setUp() {
+        context = new DefaultCamelContext();
+    }
+
+    @AfterEach
+    void tearDown() {
+        context.stop();
+    }
+
+    private IndexRequest.Builder<Object> preBuiltIndexBuilder() {
+        return new IndexRequest.Builder<>().index("idx").id("original").document(Map.of("k", "v"));
+    }
+
+    @Test
+    void preBuiltIndexBuilderKeepsItsIdWhenHeaderAbsent() throws Exception {
+        Exchange exchange = new DefaultExchange(context);
+
+        IndexRequest.Builder<?> result
+                = ElasticsearchActionRequestConverter.toIndexRequestBuilder(preBuiltIndexBuilder(), exchange);
+
+        // no CamelIndexId header -> the caller's id must be preserved, not overwritten with null
+        assertEquals("original", result.build().id());
+    }
+
+    @Test
+    void preBuiltIndexBuilderHeaderOverridesId() throws Exception {
+        Exchange exchange = new DefaultExchange(context);
+        exchange.getIn().setHeader(ElasticsearchConstants.PARAM_INDEX_ID, "fromHeader");
+
+        IndexRequest.Builder<?> result
+                = ElasticsearchActionRequestConverter.toIndexRequestBuilder(preBuiltIndexBuilder(), exchange);
+
+        assertEquals("fromHeader", result.build().id());
+    }
+}

Review Comment:
   Test comment



-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-24816: camel-elasticsearch/camel-opensearch - minor robustness fixes [camel]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #26590:
URL: https://github.com/apache/camel/pull/26590#issuecomment-5728640280

   :star2: Thank you for your contribution to the Apache Camel project! :star2:
     :robot: CI automation will test this PR automatically.
   
     :camel: Apache Camel Committers, please review the following items:
   
     * First-time contributors **require MANUAL approval** for the GitHub Actions to run
     * You can use the command `/component-test (camel-)component-name1 (camel-)component-name2..` to request a test from the test bot although they are normally detected and executed by CI.
     * You can label PRs using `skip-tests` and `test-dependents` to fine-tune the checks executed by this PR.
     * Build and test logs are available in the summary page. **Only** [Apache Camel committers](https://camel.apache.org/community/team/#committers) have access to the summary.
     
     :warning: Be careful when sharing logs. Review their contents before sharing them publicly.


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-24816: camel-elasticsearch/camel-opensearch - minor robustness fixes [camel]

Posted by "gnodet-bot (via GitHub)" <gi...@apache.org>.
gnodet-bot commented on code in PR #26590:
URL: https://github.com/apache/camel/pull/26590#discussion_r4045887362


##########
components/camel-opensearch/src/test/java/org/apache/camel/component/opensearch/converter/OpensearchActionRequestConverterTest.java:
##########
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.opensearch.converter;
+
+import java.util.Map;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.opensearch.OpensearchConstants;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.support.DefaultExchange;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.opensearch.client.opensearch.core.IndexRequest;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class OpensearchActionRequestConverterTest {
+
+    private CamelContext context;
+
+    @BeforeEach
+    void setUp() {
+        context = new DefaultCamelContext();
+    }
+
+    @AfterEach
+    void tearDown() {
+        context.stop();
+    }
+
+    private IndexRequest.Builder<Object> preBuiltIndexBuilder() {
+        return new IndexRequest.Builder<>().index("idx").id("original").document(Map.of("k", "v"));
+    }
+
+    @Test
+    void preBuiltIndexBuilderKeepsItsIdWhenHeaderAbsent() throws Exception {
+        Exchange exchange = new DefaultExchange(context);
+
+        IndexRequest.Builder<?> result
+                = OpensearchActionRequestConverter.toIndexRequestBuilder(preBuiltIndexBuilder(), exchange);
+
+        // no CamelOpensearchIndexId header -> the caller's id must be preserved, not overwritten with null
+        assertEquals("original", result.build().id());
+    }
+
+    @Test
+    void preBuiltIndexBuilderHeaderOverridesId() throws Exception {
+        Exchange exchange = new DefaultExchange(context);
+        exchange.getIn().setHeader(OpensearchConstants.PARAM_INDEX_ID, "fromHeader");
+
+        IndexRequest.Builder<?> result
+                = OpensearchActionRequestConverter.toIndexRequestBuilder(preBuiltIndexBuilder(), exchange);
+
+        assertEquals("fromHeader", result.build().id());
+    }
+}

Review Comment:
   âš ī¸ **Missing test: `UpdateRequest.Builder` id-preservation.**
   
   Same gap as the Elasticsearch component — `toUpdateRequestBuilder()` with a pre-built builder is untested. The fix is present but can silently regress. Please add the symmetric test:
   
   ```java
   @Test
   void preBuiltUpdateBuilderKeepsItsIdWhenHeaderAbsent() throws Exception {
       Exchange exchange = new DefaultExchange(context);
       // Use the OpenSearch UpdateRequest builder with a pre-set id
       var preBuilt = new org.opensearch.client.opensearch.core.UpdateRequest.Builder<Object, Object>()
           .index("idx").id("original");
   
       UpdateRequest.Builder<?, ?> result =
           OpensearchActionRequestConverter.toUpdateRequestBuilder(preBuilt, exchange);
   
       assertEquals("original", result.build().id());
   }
   ```



##########
components/camel-elasticsearch/src/test/java/org/apache/camel/component/es/converter/ElasticsearchActionRequestConverterTest.java:
##########
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.es.converter;
+
+import java.util.Map;
+
+import co.elastic.clients.elasticsearch.core.IndexRequest;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.es.ElasticsearchConstants;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.support.DefaultExchange;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class ElasticsearchActionRequestConverterTest {
+
+    private CamelContext context;
+
+    @BeforeEach
+    void setUp() {
+        context = new DefaultCamelContext();
+    }
+
+    @AfterEach
+    void tearDown() {
+        context.stop();
+    }
+
+    private IndexRequest.Builder<Object> preBuiltIndexBuilder() {
+        return new IndexRequest.Builder<>().index("idx").id("original").document(Map.of("k", "v"));
+    }
+
+    @Test
+    void preBuiltIndexBuilderKeepsItsIdWhenHeaderAbsent() throws Exception {
+        Exchange exchange = new DefaultExchange(context);
+
+        IndexRequest.Builder<?> result
+                = ElasticsearchActionRequestConverter.toIndexRequestBuilder(preBuiltIndexBuilder(), exchange);
+
+        // no CamelIndexId header -> the caller's id must be preserved, not overwritten with null
+        assertEquals("original", result.build().id());
+    }
+
+    @Test
+    void preBuiltIndexBuilderHeaderOverridesId() throws Exception {
+        Exchange exchange = new DefaultExchange(context);
+        exchange.getIn().setHeader(ElasticsearchConstants.PARAM_INDEX_ID, "fromHeader");
+
+        IndexRequest.Builder<?> result
+                = ElasticsearchActionRequestConverter.toIndexRequestBuilder(preBuiltIndexBuilder(), exchange);
+
+        assertEquals("fromHeader", result.build().id());
+    }
+}

Review Comment:
   âš ī¸ **Missing test: `UpdateRequest.Builder` id-preservation.**
   
   `toUpdateRequestBuilder()` received the same fix as `toIndexRequestBuilder()` — if `CamelIndexId` header is absent, a pre-built builder's id should not be clobbered. That path is untested. Please add:
   
   ```java
   @Test
   void preBuiltUpdateBuilderKeepsItsIdWhenHeaderAbsent() throws Exception {
       Exchange exchange = new DefaultExchange(context);
       UpdateRequest.Builder<Object, Object> preBuilt =
           new UpdateRequest.Builder<>().index("idx").id("original").doc(Map.of("k", "v"));
   
       UpdateRequest.Builder<?, ?> result =
           ElasticsearchActionRequestConverter.toUpdateRequestBuilder(preBuilt, exchange);
   
       assertEquals("original", result.build().id());
   }
   ```



-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-24816: camel-elasticsearch/camel-opensearch - minor robustness fixes [camel]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #26590:
URL: https://github.com/apache/camel/pull/26590#issuecomment-5729012540

   <!-- ci-tested-modules -->
   :test_tube: **CI tested the following changed modules:**
   
   - `components/camel-elasticsearch`
   - `components/camel-opensearch`
   
   ---
   
   <details><summary>:microscope: Scalpel shadow comparison — Scalpel: 10 tested, 27 compile-only — current: 10 all tested</summary>
   
   [Maveniverse Scalpel](https://github.com/maveniverse/scalpel) detected **37 affected modules** (current approach: 10).
   
   <details><summary>:warning: Modules only in Scalpel (27)</summary>
   
   - `apache-camel`
   - `camel-allcomponents`
   - `camel-catalog`
   - `camel-catalog-console`
   - `camel-catalog-maven`
   - `camel-catalog-suggest`
   - `camel-componentdsl`
   - `camel-endpointdsl`
   - `camel-endpointdsl-support`
   - `camel-itest`
   - `camel-jbang-core`
   - `camel-jbang-it`
   - `camel-jbang-main`
   - `camel-jbang-plugin-edit`
   - `camel-jbang-plugin-generate`
   - `camel-jbang-plugin-kubernetes`
   - `camel-jbang-plugin-test`
   - `camel-kamelet-main`
   - `camel-launcher`
   - `camel-report-maven-plugin`
   - `camel-route-parser`
   - `camel-yaml-dsl`
   - `camel-yaml-dsl-deserializers`
   - `camel-yaml-dsl-maven-plugin`
   - `coverage`
   - `docs`
   - `dummy-component`
   
   </details>
   
   **Skip-tests mode would test 10 modules** (2 direct + 8 downstream), **skip tests for 27** (generated code, meta-modules)
   
   <details><summary>Modules Scalpel would test (10)</summary>
   
   - `camel-elasticsearch`
   - `camel-jbang-mcp`
   - `camel-jbang-plugin-mcp`
   - `camel-jbang-plugin-route-parser`
   - `camel-jbang-plugin-tui`
   - `camel-jbang-plugin-validate`
   - `camel-launcher-container`
   - `camel-opensearch`
   - `camel-yaml-dsl-validator`
   - `camel-yaml-dsl-validator-maven-plugin`
   
   </details>
   
   <details><summary>Modules with tests skipped (27)</summary>
   
   - `apache-camel`
   - `camel-allcomponents`
   - `camel-catalog`
   - `camel-catalog-console`
   - `camel-catalog-maven`
   - `camel-catalog-suggest`
   - `camel-componentdsl`
   - `camel-endpointdsl`
   - `camel-endpointdsl-support`
   - `camel-itest`
   - `camel-jbang-core`
   - `camel-jbang-it`
   - `camel-jbang-main`
   - `camel-jbang-plugin-edit`
   - `camel-jbang-plugin-generate`
   - `camel-jbang-plugin-kubernetes`
   - `camel-jbang-plugin-test`
   - `camel-kamelet-main`
   - `camel-launcher`
   - `camel-report-maven-plugin`
   - `camel-route-parser`
   - `camel-yaml-dsl`
   - `camel-yaml-dsl-deserializers`
   - `camel-yaml-dsl-maven-plugin`
   - `coverage`
   - `docs`
   - `dummy-component`
   
   </details>
   
   > :information_source: Shadow mode — Scalpel observes but does not affect test execution. [Learn more](https://github.com/maveniverse/scalpel)
   
   </details>
   
   <details><summary>All tested modules (37 modules, 4m 26s total)</summary>
   
   **Total reactor time:** 4m 26s
   
   | Module | Duration | Status |
   | --- | --- | --- |
   | Camel :: Launcher | 49.8s | SUCCESS |
   | Camel :: JBang :: MCP | 38.2s | SUCCESS |
   | Camel :: JBang :: Plugin :: TUI | 32.1s | SUCCESS |
   | Camel :: Catalog :: Camel Catalog | 21.4s | SUCCESS |
   | Camel :: Component DSL | 20.3s | SUCCESS |
   | Camel :: Docs | 14.5s | SUCCESS |
   | Camel :: JBang :: Plugin :: Kubernetes | 13.7s | SUCCESS |
   | Camel :: JBang :: Plugin :: Testing | 7.9s | SUCCESS |
   | Camel :: Catalog :: Camel Report Maven Plugin | 7.6s | SUCCESS |
   | Camel :: YAML DSL :: Validator | 7.5s | SUCCESS |
   | Camel :: Catalog :: Camel Route Parser | 6.7s | SUCCESS |
   | Camel :: Kamelet Main | 6.5s | SUCCESS |
   | Camel :: JBang :: Plugin :: Validate | 5.4s | SUCCESS |
   | Camel :: All Components Sync point | 5.3s | SUCCESS |
   | Camel :: YAML DSL :: Deserializers | 4.9s | SUCCESS |
   | Camel :: YAML DSL :: Maven Plugins | 3.1s | SUCCESS |
   | Camel :: Catalog :: Suggest (deprecated) | 2.9s | SUCCESS |
   | Camel :: YAML DSL :: Validator Maven Plugin | 2.8s | SUCCESS |
   | Camel :: Catalog :: Maven | 2.3s | SUCCESS |
   | Camel :: Assembly | 1.9s | SUCCESS |
   | Camel :: JBang :: Plugin :: Edit | 1.8s | SUCCESS |
   | Camel :: Coverage | 1.6s | SUCCESS |
   | Camel :: Catalog :: Dummy Component | 1.3s | SUCCESS |
   | Camel :: JBang :: Plugin :: Generate | 1.2s | SUCCESS |
   | Camel :: JBang :: Integration tests | 1.0s | SUCCESS |
   | Camel :: JBang :: Plugin :: MCP | 0.9s | SUCCESS |
   | Camel :: Catalog :: Console | 0.9s | SUCCESS |
   | Camel :: JBang :: Main | 0.8s | SUCCESS |
   | Camel :: Launcher :: Container | 0.7s | SUCCESS |
   | Camel :: Endpoint DSL :: Support | 0.7s | SUCCESS |
   | Camel :: JBang :: Plugin :: Route Parser | 0.5s | SUCCESS |
   | Camel :: Elasticsearch Java API Client | n/a |  |
   | Camel :: Endpoint DSL | n/a |  |
   | Camel :: Integration Tests | n/a |  |
   | Camel :: JBang :: Core | n/a |  |
   | Camel :: OpenSearch Java API Client | n/a |  |
   | Camel :: YAML DSL | n/a |  |
   
   **Top 20 slowest modules:**
   - `Camel :: Launcher` (49.8s)
   - `Camel :: JBang :: MCP` (38.2s)
   - `Camel :: JBang :: Plugin :: TUI` (32.1s)
   - `Camel :: Catalog :: Camel Catalog` (21.4s)
   - `Camel :: Component DSL` (20.3s)
   - `Camel :: Docs` (14.5s)
   - `Camel :: JBang :: Plugin :: Kubernetes` (13.7s)
   - `Camel :: JBang :: Plugin :: Testing` (7.9s)
   - `Camel :: Catalog :: Camel Report Maven Plugin` (7.6s)
   - `Camel :: YAML DSL :: Validator` (7.5s)
   - `Camel :: Catalog :: Camel Route Parser` (6.7s)
   - `Camel :: Kamelet Main` (6.5s)
   - `Camel :: JBang :: Plugin :: Validate` (5.4s)
   - `Camel :: All Components Sync point` (5.3s)
   - `Camel :: YAML DSL :: Deserializers` (4.9s)
   - `Camel :: YAML DSL :: Maven Plugins` (3.1s)
   - `Camel :: Catalog :: Suggest (deprecated)` (2.9s)
   - `Camel :: YAML DSL :: Validator Maven Plugin` (2.8s)
   - `Camel :: Catalog :: Maven` (2.3s)
   - `Camel :: Assembly` (1.9s)
   
   </details>
   
   ---
   :gear: [View full build and test results](https://github.com/apache/camel/actions/runs/35334109937)


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-24816: camel-elasticsearch/camel-opensearch - minor robustness fixes [camel]

Posted by "oscerd (via GitHub)" <gi...@apache.org>.
oscerd commented on PR #26590:
URL: https://github.com/apache/camel/pull/26590#issuecomment-5757021700

   Thanks for the review. Addressed the missing-test feedback in the latest commit: added `preBuiltUpdateBuilderKeepsItsIdWhenHeaderAbsent` to both the Elasticsearch and OpenSearch converter tests, so the `toUpdateRequestBuilder` id-preservation fix is now covered symmetrically with `toIndexRequestBuilder`.
   
   _Claude Code on behalf of Andrea Cosentino (@oscerd)_


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-24816: camel-elasticsearch/camel-opensearch - minor robustness fixes [camel]

Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on PR #26590:
URL: https://github.com/apache/camel/pull/26590#issuecomment-5772611142

   <!-- camel-backport-bot -->
   
   ### 🔄 Backport Bot
   
   **Port PRs created:**
   - ✅ `camel-4.22.x` → #26722
   
   **Conflicts (🤖 agent dispatched to resolve):**
   - âš ī¸ `camel-4.18.x` — Cherry-pick conflict in: components/camel-elasticsearch/src/main/java/org/apache/camel/component/es/converter/ElasticsearchActionRequestConverter.java, components/camel-opensearch/src/main/java/org/apache/camel/component/opensearch/OpensearchProducer.java
   
   â„šī¸ If you push additional commits after `/port`, use `/port` again to update the port PRs.


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org