Skip to content

fix: Keep the query string in the HTTP wait strategy path - #1807

Merged
HofmeisterAn merged 2 commits into
testcontainers:developfrom
johnkaram02:fix/http-wait-strategy-query-string
Oct 28, 2026
Merged

HofmeisterAn merged 2 commits into
testcontainers:developfrom
johnkaram02:fix/http-wait-strategy-query-string

Conversation

@johnkaram02

@johnkaram02 johnkaram02 commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

HttpWaitStrategy now splits the value passed to ForPath(string) at the first ? and sets the remainder as the UriBuilder query. Before this change, the whole value went to the UriBuilder path, which escapes ?, so ForPath("/health?ready=1") sent GET /health%3Fready=1.

The PR adds HttpWaitStrategySendsQueryString to WaitUntilHttpRequestIsSucceededTest. It uses the existing socat fixture, which logs the raw request, and checks that the request line contains the query string.

Why is it important?

Some health endpoints need a query parameter. Without the query string they return 404 or another unexpected status, so the wait strategy retries until it times out.

Related issues

  • Closes #<issue number, if one is opened>

How to test this PR

dotnet test tests/Testcontainers.Tests --filter "FullyQualifiedName~WaitUntilHttpRequestIsSucceededTest" (needs Docker). The new test fails on develop because the request line is GET /health%3Fready=1&probe=startup HTTP/1.1, and passes with this change.

Summary by CodeRabbit

  • Bug Fixes
    • HTTP-based readiness checks now correctly handle request paths with query parameters, including multiple parameters. Query characters are preserved when the request is sent, helping checks succeed when the configured URL includes a query string. The resulting HTTP request also retains the configured query string in its request line, as reflected in container logs.

HttpWaitStrategy passed the configured path to UriBuilder as the path
component. UriBuilder escapes "?", so ForPath("/health?ready=1") sent
"GET /health%3Fready=1" and the container never received the query
string. Endpoints that need a query parameter returned an unexpected
status and the wait strategy did not succeed.

Split the configured value at the first "?" and set the remainder as
the UriBuilder query.
@netlify

netlify Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for testcontainers-dotnet ready!

Name Link
🔨 Latest commit 47fd092
🔍 Latest deploy log https://app.netlify.com/projects/testcontainers-dotnet/deploys/6ae21e17e3f57542fada9bff
😎 Deploy Preview https://deploy-preview-1807--testcontainers-dotnet.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7e87a849-c070-43a0-9c3f-6b52cc500e93
Commits

Reviewing files that changed from the base of the PR and between 18ae465 and 47fd092.

Files selected for processing: 2
  • src/Testcontainers/Configurations/WaitStrategies/HttpWaitStrategy.cs
  • tests/Testcontainers.Tests/Unit/Configurations/WaitUntilHttpRequestIsSucceededTest.cs
Files skipped from review as they are similar to previous changes: 1
  • tests/Testcontainers.Tests/Unit/Configurations/WaitUntilHttpRequestIsSucceededTest.cs

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Walkthrough

HttpWaitStrategy.UntilAsync now separates a configured query string from the request path before building the URI. A unit test checks that the wait succeeds and that the logged request includes the query string.

Changes

HTTP Wait Query Handling

Layer / File(s) Summary
Separate query from request path
src/Testcontainers/Configurations/WaitStrategies/HttpWaitStrategy.cs, tests/Testcontainers.Tests/Unit/Configurations/WaitUntilHttpRequestIsSucceededTest.cs
UntilAsync assigns the path and query separately to UriBuilder. A unit test checks a request to /health?ready=1&probe=startup, the successful wait, and the logged request.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: Low · up to 47fd0

Only unusual query values beginning with a question mark remain affected; ordinary query strings are handled correctly.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: preserving query strings in the HTTP wait strategy path.
Description check Passed The description explains what changed, why it matters, the added test, and how to run the test. The related issue entry uses a placeholder, but that section is recommended rather than mandatory.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 2 files.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit checks the health route,
With query strings carried clear.
The wait succeeds, the logs confirm,
Each parameter arrives here.
I twitch my nose and hop away,
While paths and queries persevere.

Comment @coderabbitai help to get the list of available commands.

@HofmeisterAn HofmeisterAn added the bug Something isn't working label Oct 28, 2026

@HofmeisterAn HofmeisterAn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks!

@HofmeisterAn
HofmeisterAn merged commit 73d9766 into testcontainers:develop Oct 28, 2026
374 of 393 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants