Skip to content

fix(listen): join the forwarding URL path and the event path with a single slash - #478

Open
pcbeingused333 wants to merge 5 commits into
hookdeck:mainfrom
pcbeingused333:fix/listen-trailing-slash-forward-url
Open

pcbeingused333 wants to merge 5 commits into
hookdeck:mainfrom
pcbeingused333:fix/listen-trailing-slash-forward-url

Conversation

@pcbeingused333

Copy link
Copy Markdown

Fixes #475.

processAttempt builds the forwarded URL as cfg.URL.Path + webhookEvent.Body.Path, so a forwarding URL whose path ends in / (hookdeck listen http://127.0.0.1:47913/base/ <source>) sends every request to /base//webhook instead of /base/webhook.

The two paths are now joined by joinForwardPath, which drops one trailing / from the forwarding URL's path when the event path starts with /. The event path is otherwise kept as is, since a receiver may route on its own trailing slash (which is why path.Join is not used), and an empty event path still forwards to the forwarding URL's path unchanged.

forward_path_test.go runs one attempt through processAttempt against a local server for six cases: forwarding path with and without a trailing slash, the root, no path, an event path with its own trailing slash, and an empty event path. On master the three cases whose forwarding path ends in / (/base/, / and an event path with its own trailing slash) fail with //; with this change all six pass. go vet ./... passes. go test ./... passes apart from two tests in packages this change does not touch, which fail the same way on master in the container used: TestCheckServerHealth_DefaultPorts/HTTPS_default_port (needs an outbound connection to port 443) and TestLogin_rejectedKeyHeadlessFailsFast in pkg/login. The acceptance tests were not run.

The issue also notes that a query string on the forwarding URL is dropped; that is not changed here, since forwarding it or rejecting it at startup is a behaviour choice.

This change was prepared with Claude Code.

…ingle slash

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@pcbeingused333

Copy link
Copy Markdown
Author

Hi, friendly ping on this one when you have a moment. Happy to adjust anything or rebase if needed. Thanks for maintaining the project!

leggetter and others added 3 commits November 12, 2026 00:23
The request URL was joined with a single slash, but the URL printed in the
compact and interactive output, the TUI event details and the TUI connection
header was still concatenated by hand. A forwarding URL ending in / therefore
printed /base//webhook for a request sent to /base/webhook, and the TUI
details and header dropped the forwarding URL's path altogether.

Move the join into pkg/listen/forwardurl and use it at all five places, with
one test per place.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…L is dropped

Whether the query string should be forwarded or rejected is undecided (see
hookdeck#475), so the forwardurl test should not pin the current behaviour.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@leggetter

Copy link
Copy Markdown
Collaborator

Thanks for this, and sorry for the wait. The fix to the forwarded request looks right, and the new test fails on main in exactly the // cases, so it pins the change.

While checking it I found the same // in the URL the CLI prints, which is built separately from the request URL. I've pushed a commit to this branch that covers it, so the printed URL matches the one the request went to:

  • pkg/listen/forwardurl now holds the join (moved out of proxy.go), and proxy.go calls it.
  • The compact and interactive output lines use it.
  • The TUI event details and the TUI "Forwards to →" header use it too. Both used to leave out the forwarding URL's path.
  • There is one test per place.

I merged main into the branch rather than rebasing, so your commit is unchanged. CI is approved and running.

The compact startup banner built its "Forwards to" URL from the scheme and
host only, so it left out the forwarding URL's path and could disagree with
the URL the request is sent to. Build it with pkg/listen/forwardurl like the
other places that print the forwarded URL.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.

listen: a trailing slash on the forwarding URL produces // in the forwarded path

2 participants