Skip to content

CAMEL-23698: Do not append trailing ? to URI when query string is empty#23797

Merged
davsclaus merged 1 commit into
mainfrom
fix/CAMEL-23698
Jun 5, 2026
Merged

CAMEL-23698: Do not append trailing ? to URI when query string is empty#23797
davsclaus merged 1 commit into
mainfrom
fix/CAMEL-23698

Conversation

@davsclaus
Copy link
Copy Markdown
Contributor

Summary

  • Fix URISupport.createURIWithQuery() to not append a bare ? when the query string is empty
  • When camel-rest-openapi produces a REST call from an OpenAPI spec with optional query parameters that are not set, the URL ended with a trailing ? (e.g., /users/myuser/repos? instead of /users/myuser/repos)
  • Some HTTP servers and proxies treat /resource and /resource? differently, so this can cause issues

Root Cause

URISupport.createURIWithQuery() checked if (query != null) before appending ? + query, but did not check if the query string was empty. Changed to if (query != null && !query.isEmpty()).

Test plan

  • Added testCreateURIWithQueryEmptyQueryString in URISupportTest verifying no trailing ? is appended for empty query strings
  • Existing URISupportTest tests pass (null query and non-empty query cases)

Claude Code on behalf of Claus Ibsen

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 5, 2026

🌟 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.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 5, 2026

🧪 CI tested the following changed modules:

  • core/camel-util

ℹ️ 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.


⚙️ View full build and test results

…string is empty

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
@github-actions github-actions Bot removed the dsl label Jun 5, 2026
Copy link
Copy Markdown
Contributor Author

@davsclaus davsclaus left a comment

Choose a reason for hiding this comment

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

Reviewed — looks good to merge.

  • The !query.isEmpty() guard on createURIWithQuery() is the right fix. The original null-only check (from 2011) never handled empty strings, but camel-rest-openapi can produce them when all optional query params are unset.
  • Checked all 6 production callers (URISupport, ResourceHelper, HttpProducer, HttpHelper, NettyHttpHelper, UndertowHelper) — none rely on appending a bare ? for empty queries. They all benefit from this fix.
  • Test coverage is appropriate: the new test complements the existing null and non-empty cases.
  • No regression risk.

This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.

@davsclaus davsclaus merged commit 5a65332 into main Jun 5, 2026
5 checks passed
@davsclaus davsclaus deleted the fix/CAMEL-23698 branch June 5, 2026 21:01
davsclaus added a commit that referenced this pull request Jun 5, 2026
…string is empty (#23797) (#23801)

Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant