Skip to content

Add option to encode raw semicolons in query strings - #157

Open
aharpervc wants to merge 1 commit into
basecamp:mainfrom
aharpervc:encode-query-semicolons
Open

aharpervc wants to merge 1 commit into
basecamp:mainfrom
aharpervc:encode-query-semicolons

Conversation

@aharpervc

Copy link
Copy Markdown

Go's URL parser rejects query pairs containing an unencoded semicolon, and ReverseProxy removes them from the outbound request. Clients that send values like ?a=1;2 lose the whole parameter without any error (!!!). This was really surprising, and I discovered it accidentally/unfortunately when moving a Rails app to thruster.

I am aware that it's normal/preferred for clients to encode semicolons in the request url, but it was only when switching to thruster that not doing that became impossible.

This PR introduces a config option to help out. When ENCODE_QUERY_SEMICOLONS is enabled, raw semicolons are encoded as %3B before caching and proxying, so they are passed upstream (eg Rails) as part of the value and requests with different values get distinct cache keys.

Related discussions

Go's URL parser rejects query pairs containing an unencoded semicolon,
and ReverseProxy removes them from the outbound request. Clients that
send values like ?a=1;2 lose the whole parameter without any error.

When ENCODE_QUERY_SEMICOLONS is enabled, raw semicolons are encoded as
%3B before caching and proxying, so they are passed upstream as part of
the value and requests with different values get distinct cache keys.
Copilot AI balanced review requested due to automatic review settings October 2, 2026 14:04

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approved

The implementation is scoped, correctly ordered in the handler stack, documented, and adequately tested.

Review effort: Balanced
Findings: None

What changed in this PR

Adds opt-in preservation of raw query-string semicolons before caching and proxying.

Changes:

  • Adds the ENCODE_QUERY_SEMICOLONS configuration option.
  • Encodes raw semicolons as %3B before cache lookup and proxying.
  • Tests encoding, disabled behavior, configuration, and cache-key handling.

[!TIP]
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

File Description
README.md Documents the new environment variable.
internal/​service.go Passes configuration into the handler stack.
internal/​query_semicolon_handler.go Implements opt-in semicolon encoding.
internal/​query_semicolon_handler_test.go Tests proxy and cache behavior.
internal/​handler.go Places encoding before caching and proxying.
internal/​config.go Loads the new configuration option.
internal/​config_test.go Tests default and overridden configuration.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants