Skip to content

fix(middleware): preserve query strings in profiler redirects - #1202

Open
sergioperezcheco wants to merge 1 commit into
go-chi:masterfrom
sergioperezcheco:fix/profiler-query-redirect-20261004
Open

sergioperezcheco wants to merge 1 commit into
go-chi:masterfrom
sergioperezcheco:fix/profiler-query-redirect-20261004

Conversation

@sergioperezcheco

Copy link
Copy Markdown

Profiler appended redirect suffixes to RequestURI, so /debug/pprof?debug=1 redirected to /debug/pprof?debug=1/ instead of /debug/pprof/?debug=1. Following that redirect never reached the pprof index.

This appends the suffix to a copied URL's path and escaped path, preserving the raw query and full mount prefix. The root redirect also normalizes /debug/ to /debug/pprof/ rather than the previous double-slash path. Regression tests use real HTTP requests for root and pprof entry points, nested and escaped mount prefixes, and queries with repeated keys; they follow each redirect to the real pprof index.

The regression fails against the original implementation. The full module race suite, vet, goimports and incremental staticcheck pass locally on Go 1.26.4/macOS arm64. Other Go versions and the Linux/Windows CI matrix have not been run locally.

Implemented and verified with AI assistance through Hermes Agent.

Implemented and tested with AI assistance through Hermes Agent.

Signed-off-by: sergioperezcheco <checo520@outlook.com>

This branch has not been deployed

No deployments
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.

1 participant