You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "cunningt (via GitHub)" <gi...@apache.org> on 2026/05/21 01:55:58 UTC

[PR] CAMEL-23594: Fix property resolution issues in kamelet endpoint URIs [camel]

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

   ## Problem
   
   Kamelet integration tests were failing due to two property resolution issues:
   
   1. **Trailing whitespace in property values** — YAML literal block scalars (`|`) preserve trailing newlines, which cause `URISyntaxException` when the property value is resolved into an endpoint URI string.
   
   2. **URL-encoded property values** — The YAML DSL uses `URISupport.createQueryString()` to build kamelet URIs, which URL-encodes property values (e.g., `application/json` → `application%2Fjson`). Since `KameletComponent` uses `useRawUri()=true` to preserve sensitive values, automatic URL-decoding during URI parsing is skipped, leaving encoded values like `application%2Fjson` to be passed to kamelet templates.
   
   ## Solution
   
   ### Fix 1: Trim whitespace in DefaultPropertiesParser
   
   **File:** `core/camel-base/src/main/java/org/apache/camel/component/properties/DefaultPropertiesParser.java`
   
   Added `.trim()` when returning resolved property values in `doGetPropertyValue()`. This strips leading/trailing whitespace, which is safe since no legitimate property value depends on surrounding whitespace.
   
   ### Fix 2: URL-decode kamelet parameters
   
   **File:** `components/camel-kamelet/src/main/java/org/apache/camel/component/kamelet/KameletComponent.java`
   
   Added URL-decoding for non-RAW string parameter values in `createEndpoint()`, between extraction and RAW resolution. This reverses the encoding done by `URISupport.createQueryString()` while preserving RAW-wrapped sensitive values (which use `RAW()` syntax and skip URL encoding).
   
   ## Testing
   
   - ✅ All 91 property component tests pass (`org.apache.camel.component.properties.*Test`)
   - ✅ All 81 kamelet component tests pass
   - ✅ All 337 YAML DSL tests pass
   
   These fixes resolve kamelet integration test failures where:
   - Property values with trailing newlines caused `URISyntaxException`
   - URL-encoded values like `application%2Fjson` were incorrectly passed as `Content-Type` headers, causing HTTP 415 errors
   
   ## Related Issues
   
   CAMEL-23594


-- 
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-23594: Fix property resolution issues in kamelet endpoint URIs [camel]

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

   Replaced by #24170 


-- 
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-23594: Fix property resolution issues in kamelet endpoint URIs [camel]

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

   Thank you for the feedback!   I'm working on changes to minimize the scope of where trim / decode run and target kamelets. 
   
   The issue here I see is that there are 7 transformation kamelet integration tests failing : https://github.com/apache/camel-kamelets/actions/runs/26155039895/job/76932071431
   
   > Error:    CommonIT.transformation()[1] » TestCaseFailed Action timeout after 60000 milliseconds. Failed to receive message on endpoint: 'httpServer.inbound'
   > Error:    CommonIT.transformation()[2] » TestCaseFailed Action timeout after 60000 milliseconds. Failed to receive message on endpoint: 'httpServer.inbound'
   > Error:    CommonIT.transformation()[3] » TestCaseFailed Action timeout after 60000 milliseconds. Failed to receive message on endpoint: 'httpServer.inbound'
   > Error:    CommonIT.transformation()[4] » TestCaseFailed Action timeout after 60000 milliseconds. Failed to receive message on endpoint: 'httpServer.inbound'
   > Error:    CommonIT.transformation()[5] » TestCaseFailed Action timeout after 60000 milliseconds. Failed to receive message on endpoint: 'httpServer.inbound'
   > Error:    CommonIT.transformation()[6] » TestCaseFailed Action timeout after 60000 milliseconds. Failed to receive message on endpoint: 'httpServer.inbound'
   > Error:    CommonIT.transformation()[7] » TestCaseFailed Action timeout after 60000 milliseconds. Failed to receive message on endpoint: 'httpServer.inbound'
   
   The big issue here is that the content type is being URL-encoded and application/json → application%2Fjson, causing unexpected behavior and lots of test failures.


-- 
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-23594: Fix property resolution issues in kamelet endpoint URIs [camel]

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


##########
components/camel-kamelet/src/main/java/org/apache/camel/component/kamelet/KameletComponent.java:
##########
@@ -132,6 +134,18 @@ protected Endpoint createEndpoint(String uri, String remaining, Map<String, Obje
         parameters.remove(PARAM_LOCATION);
         parameters.remove(PARAM_UUID);
 
+        // URL-decode non-RAW parameter values. The YAML DSL URL-encodes property values
+        // when building query strings (via URISupport.createQueryString), but useRawUri=true
+        // prevents automatic decoding during URI parsing. Decode here so values like
+        // "application/json" are not left as "application%2Fjson".
+        for (Map.Entry<String, Object> entry : parameters.entrySet()) {
+            if (entry.getValue() instanceof String s
+                    && !s.startsWith(URISupport.RAW_TOKEN_PREFIX + "(")
+                    && !s.startsWith(URISupport.RAW_TOKEN_PREFIX + "{")) {
+                entry.setValue(URLDecoder.decode(s, StandardCharsets.UTF_8));

Review Comment:
   `createEndpoint()` is called from all DSLs (Java, XML, YAML), not just YAML. If a value arrives without URL-encoding (e.g., from Java DSL `to("kamelet:foo?contentType=application/json")`), `URLDecoder.decode()` will still process it. While `application/json` survives decoding, a value containing `%` (like `100%done`) would be corrupted or throw an `IllegalArgumentException`.
   
   Consider either:
   - Fixing the encoding at the source (the YAML DSL's `URISupport.createQueryString()` call) so values aren't double-encoded
   - Or guarding this decode with a check that the value actually contains URL-encoded sequences (e.g., `%xx` patterns)



##########
core/camel-base/src/main/java/org/apache/camel/component/properties/DefaultPropertiesParser.java:
##########
@@ -514,7 +514,7 @@ private String doGetPropertyValue(String key, String defaultValue) {
             if (answer == null) {
                 answer = value;
             }
-            return answer;
+            return answer != null ? answer.trim() : null;

Review Comment:
   This `.trim()` applies to **every** property resolution across the entire framework, not just YAML/kamelet scenarios. Property values that legitimately contain leading/trailing whitespace (passwords with trailing spaces, PEM data, regex patterns) would be silently corrupted.
   
   The root cause is YAML literal block scalars (`|`) preserving trailing newlines. This should be fixed at the YAML parsing layer where the newline is introduced, not in the global properties parser.
   
   Consider removing this change and instead trimming at the YAML DSL level where property values are extracted from block scalars.



-- 
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-23594: Fix property resolution issues in kamelet endpoint URIs [camel]

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


##########
core/camel-base/src/main/java/org/apache/camel/component/properties/DefaultPropertiesParser.java:
##########
@@ -514,7 +514,7 @@ private String doGetPropertyValue(String key, String defaultValue) {
             if (answer == null) {
                 answer = value;
             }
-            return answer;
+            return answer != null ? answer.trim() : null;

Review Comment:
   This `.trim()` applies to **every** property resolution across the entire Camel framework -- system properties, environment variables, `.properties` files, Spring Boot config, etc. Property values that legitimately contain trailing whitespace (passwords, PEM data, regex, template strings) would be silently corrupted.
   
   The root cause is YAML literal block scalars (`|`) preserving trailing newlines. Please fix this at the YAML parsing layer where property values are extracted, not in the global properties parser.
   
   Suggest removing this change entirely.
   
   _Claude Code on behalf of Guillaume Nodet_



##########
components/camel-kamelet/src/main/java/org/apache/camel/component/kamelet/KameletComponent.java:
##########
@@ -132,6 +134,18 @@ protected Endpoint createEndpoint(String uri, String remaining, Map<String, Obje
         parameters.remove(PARAM_LOCATION);
         parameters.remove(PARAM_UUID);
 
+        // URL-decode non-RAW parameter values. The YAML DSL URL-encodes property values
+        // when building query strings (via URISupport.createQueryString), but useRawUri=true
+        // prevents automatic decoding during URI parsing. Decode here so values like
+        // "application/json" are not left as "application%2Fjson".
+        for (Map.Entry<String, Object> entry : parameters.entrySet()) {
+            if (entry.getValue() instanceof String s
+                    && !s.startsWith(URISupport.RAW_TOKEN_PREFIX + "(")
+                    && !s.startsWith(URISupport.RAW_TOKEN_PREFIX + "{")) {
+                entry.setValue(URLDecoder.decode(s, StandardCharsets.UTF_8));

Review Comment:
   `URLDecoder.decode()` will throw `IllegalArgumentException` on values containing bare `%` characters (e.g., `100%complete` or `[a-z]%[0-9]`). This `createEndpoint()` method is called from all DSLs, not just YAML, so non-encoded values will reach here.
   
   Consider either:
   1. **Fix at the source**: use `createQueryString(params, false)` in `YamlRoutesBuilderLoader` for kamelet URIs (like `KameletDeserializer` and `YamlSupport` already do with `encode=false`). This would be consistent with the CAMEL-23284 approach.
   2. **Or guard the decode**: at minimum wrap in try/catch `IllegalArgumentException` and fall back to the original value.
   
   ```suggestion
           for (Map.Entry<String, Object> entry : parameters.entrySet()) {
               if (entry.getValue() instanceof String s
                       && !s.startsWith(URISupport.RAW_TOKEN_PREFIX + "(")
                       && !s.startsWith(URISupport.RAW_TOKEN_PREFIX + "{")) {
                   try {
                       entry.setValue(URLDecoder.decode(s, StandardCharsets.UTF_8));
                   } catch (IllegalArgumentException e) {
                       // value contains bare % not part of URL encoding, leave as-is
                   }
               }
           }
   ```
   
   Though option 1 (fixing the encoding at the YAML DSL source) would be the cleanest solution.
   
   _Claude Code on behalf of Guillaume Nodet_



-- 
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-23594: Fix property resolution issues in kamelet endpoint URIs [camel]

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

   I think the double decoding is a bit weird. Also can you point to which kamelts yaml files are having problems. It can be that they do wrong yaml - when you have multi line its |= vs >= etc


-- 
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-23594: Fix property resolution issues in kamelet endpoint URIs [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus closed pull request #23391: CAMEL-23594: Fix property resolution issues in kamelet endpoint URIs
URL: https://github.com/apache/camel/pull/23391


-- 
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-23594: Fix property resolution issues in kamelet endpoint URIs [camel]

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

   <!-- ci-tested-modules -->
   :test_tube: **CI tested the following changed modules:**
   
   - `components/camel-kamelet`
   - `core/camel-base`
   
   > :information_source: Dependent modules were not tested because the total number of affected modules exceeded the threshold (50). Use the `test-dependents` label to force testing all dependents.
   
   <details><summary>Build reactor — dependencies compiled but only changed modules were tested (2 modules)</summary>
   
   - Camel :: Base
   - Camel :: Kamelet
   
   </details>
   
   ---
   :gear: [View full build and test results](https://github.com/apache/camel/actions/runs/26200837385)


-- 
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-23594: Fix property resolution issues in kamelet endpoint URIs [camel]

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

   :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