Skip to content

CAMEL-24147: camel-lra - URL-encode callback query parameters and fix parseQuery split#24831

Merged
davsclaus merged 1 commit into
mainfrom
fix/CAMEL-24147
Jul 17, 2026
Merged

CAMEL-24147: camel-lra - URL-encode callback query parameters and fix parseQuery split#24831
davsclaus merged 1 commit into
mainfrom
fix/CAMEL-24147

Conversation

@davsclaus

Copy link
Copy Markdown
Contributor

Summary

Claude Code on behalf of davsclaus

Two related defects in camel-lra cause saga compensation/completion to silently fail when endpoint URIs contain query parameters or special characters:

  • LRAUrlBuilder.query() concatenated keys and values raw with no URLEncoder. An endpoint URI like seda:cancelOrder?concurrentConsumers=2&size=1000 corrupts the callback URL registered with the LRA coordinator.
  • LRASagaRoutes.parseQuery() used split("=") without a limit, dropping everything after the second = in a value.

Changes

  • LRAUrlBuilder.query(): URL-encode both key and value with URLEncoder.encode()
  • LRASagaRoutes.parseQuery(): use split("=", 2) to preserve values containing =
  • Added LRAUrlBuilderTest with encoding and round-trip tests
  • Added new test cases to LRASagaRoutesTest for encoded special characters and equals-in-value

Test plan

  • New LRAUrlBuilderTest verifies encoding of special characters, round-trip fidelity, and realistic compensation URIs with query parameters
  • New LRASagaRoutesTest cases verify parseQuery() handles encoded &, =, + and preserves values with =
  • All 9 tests pass in mvn verify

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

… parseQuery split

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
@davsclaus
davsclaus requested review from Croway and gnodet July 17, 2026 08:40
@github-actions

Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 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 have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code on behalf of gnodet

LGTM — fixes two related URL-handling bugs that silently corrupt LRA callback URLs.

Bug 1 — missing URL-encoding in LRAUrlBuilder.query():
An endpoint URI like seda:cancelOrder?concurrentConsumers=2&size=1000 registered as a compensation callback would have its ?, &, and = characters interpreted as part of the callback URL's own query structure, corrupting the registered callback. The fix correctly applies URLEncoder.encode(value, StandardCharsets.UTF_8) to both key and value.

Bug 2 — split("=") without limit in parseQuery():
Values containing = (e.g., URL-encoded endpoint URIs after decoding, or base64 values) would be silently truncated at the second =. split("=", 2) correctly limits the split to [key, rest-of-value].

Review notes:

  1. Both fixes work in concert — the builder now encodes special characters, and the parser correctly handles the full value after decoding.

  2. The round-trip test is excellent — verifies that LRAUrlBuilder encoding + parseQuery decoding is lossless for realistic compensation URIs with query parameters and special characters.

  3. URLEncoder.encode() with StandardCharsets.UTF_8 is the correct choice — it handles all RFC 3986 reserved characters and the decode() method already used in parseQuery() uses URLDecoder.decode() with UTF-8.

  4. No upgrade guide needed — this is a pure bugfix for behavior that was silently broken (data corruption), not a behavioral change users might rely on.

@github-actions

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • components/camel-lra

🔬 Scalpel shadow comparison — Scalpel: 9 tested, 29 compile-only — current: 9 all tested

Maveniverse Scalpel detected 38 affected modules (current approach: 9).

⚠️ Modules only in Scalpel (29)
  • apache-camel
  • camel-allcomponents
  • camel-catalog
  • camel-catalog-console
  • camel-catalog-lucene
  • camel-catalog-maven
  • camel-catalog-suggest
  • camel-componentdsl
  • camel-csimple-maven-plugin
  • 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

Skip-tests mode would test 9 modules (1 direct + 8 downstream), skip tests for 29 (generated code, meta-modules)

Modules Scalpel would test (9)
  • camel-jbang-mcp
  • camel-jbang-plugin-mcp
  • camel-jbang-plugin-route-parser
  • camel-jbang-plugin-tui
  • camel-jbang-plugin-validate
  • camel-launcher-container
  • camel-lra
  • camel-yaml-dsl-validator
  • camel-yaml-dsl-validator-maven-plugin
Modules with tests skipped (29)
  • apache-camel
  • camel-allcomponents
  • camel-catalog
  • camel-catalog-console
  • camel-catalog-lucene
  • camel-catalog-maven
  • camel-catalog-suggest
  • camel-componentdsl
  • camel-csimple-maven-plugin
  • 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

ℹ️ Shadow mode — Scalpel observes but does not affect test execution. Learn more

All tested modules (38 modules)
  • Camel :: All Components Sync point
  • Camel :: Assembly
  • Camel :: Catalog :: CSimple Maven Plugin (deprecated)
  • Camel :: Catalog :: Camel Catalog
  • Camel :: Catalog :: Camel Report Maven Plugin
  • Camel :: Catalog :: Camel Route Parser
  • Camel :: Catalog :: Console
  • Camel :: Catalog :: Dummy Component
  • Camel :: Catalog :: Lucene (deprecated)
  • Camel :: Catalog :: Maven
  • Camel :: Catalog :: Suggest
  • Camel :: Component DSL
  • Camel :: Coverage
  • Camel :: Docs
  • Camel :: Endpoint DSL
  • Camel :: Endpoint DSL :: Support
  • Camel :: Integration Tests
  • Camel :: JBang :: Core
  • Camel :: JBang :: Integration tests
  • Camel :: JBang :: MCP
  • Camel :: JBang :: Main
  • Camel :: JBang :: Plugin :: Edit
  • Camel :: JBang :: Plugin :: Generate
  • Camel :: JBang :: Plugin :: Kubernetes
  • Camel :: JBang :: Plugin :: MCP
  • Camel :: JBang :: Plugin :: Route Parser
  • Camel :: JBang :: Plugin :: TUI
  • Camel :: JBang :: Plugin :: Testing
  • Camel :: JBang :: Plugin :: Validate
  • Camel :: Kamelet Main
  • Camel :: Launcher
  • Camel :: Launcher :: Container
  • Camel :: Long-Running-Action
  • Camel :: YAML DSL
  • Camel :: YAML DSL :: Deserializers
  • Camel :: YAML DSL :: Maven Plugins
  • Camel :: YAML DSL :: Validator
  • Camel :: YAML DSL :: Validator Maven Plugin

⚙️ View full build and test results

@davsclaus davsclaus added this to the 4.22.0 milestone Jul 17, 2026
@davsclaus davsclaus added the bug Something isn't working label Jul 17, 2026
@davsclaus davsclaus self-assigned this Jul 17, 2026
@davsclaus
davsclaus merged commit ec619f2 into main Jul 17, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants