Fix #2249: stop the pulsar serviceUrl being URI-decoded twice - #2999
Merged
Conversation
serviceUrl was interpolated raw into the pulsar endpoint URI, so its value went through query parameter decoding twice: once for the kamelet: URI the caller writes, and again when the template builds pulsar:...?serviceUrl=. A "+" survives the first pass and becomes a space on the second, so the common pulsar+ssl:// scheme arrives at the client as "pulsar ssl://": Invalid service-url pulsar ssl://localhost:1234 provided java.net.URISyntaxException: Illegal character in scheme name at index 6 Still reproduces on 4.21, two years after the report on 4.8. Wrapping the placeholder in RAW() inside the template protects the value on the inner hop, which is where the second decode happened. Verified both ways against the real component: serviceUrl=pulsar+ssl://localhost:1234 -> resolves intact serviceUrl=RAW(pulsar+ssl://localhost:1234) -> resolves intact so the plain value now works as users expect, and the double-RAW workaround from the issue keeps working rather than breaking. The Pulsar client confirms the scheme survives: No available hosts found for service url: pulsar+ssl://localhost:1234 pulsar-source carried the identical interpolation and is fixed with it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2249.
Two years on, this still reproduces — I hit it on Camel 4.21 with the exact snippet from the issue:
Cause
serviceUrlwas interpolated straight into the endpoint URI:so the value is query-parameter decoded twice — once for the
kamelet:URI the caller writes, and again when the template assemblespulsar:...?serviceUrl=. A+survives the first pass and becomes a space on the second, which is why the very commonpulsar+ssl://scheme reaches the Pulsar client aspulsar ssl://.That is also exactly why the reporter's double-
RAW()workaround works: oneRAWper decode.Fix
Wrap the placeholder in
RAW()inside the template, protecting the value on the inner hop where the second decode happened:pulsar-sourcecarried the identical interpolation, so it is fixed alongside — the report only mentions the sink, but the source would fail the same way against a TLS broker.Verification
Ran both spellings against the real component. Neither produces the
URISyntaxExceptionany more, and the Pulsar client confirms the scheme survived:serviceUrl: pulsar+ssl://localhost:1234No available hosts found for service url: pulsar+ssl://localhost:1234serviceUrl: RAW(pulsar+ssl://localhost:1234)Reaching "no available hosts" is the success condition here — it means the URL parsed and the client tried to connect, with the
+intact. There is no broker on localhost, which is all that fails.Both spellings mattering is the point: the plain value now behaves as users expect, and the double-
RAWworkaround from the issue keeps working rather than breaking for anyone who already adopted it.script/validatorreports no errors andmvn clean installpasses with tests from the repository root.Note for reviewers
I scoped this to
serviceUrl, the property in the report and the only one whose documented values routinely contain a+. The same double-decode applies in principle to any pulsar property carrying URI-significant characters —authenticationParamsis the plausible next one — but I would rather not blanket-wrap properties on speculation, sinceRAW()also changes how a trailing)is treated. Happy to extend it if you would prefer the whole parameter block hardened.Claude Code on behalf of Andrea Cosentino