Description
hookdeck listen with a forwarding URL whose path ends in / forwards every request to a path containing //. The forwarding URL's path and the event's path are concatenated without being joined.
Environment
hookdeck-cli3.1.0 (Homebrew), macOS- An Event Gateway project; a source with a connection to a CLI destination whose path is
/webhook
Steps to reproduce
-
Forward to a URL with a trailing slash:
hookdeck listen http://127.0.0.1:47913/base/ <source> --output compact
-
Send one request to the source URL, and one to a path under it (
<source URL>/mcp/events/webhook/abc).
Actual
[200] POST http://127.0.0.1:47913/base//webhook
[200] POST http://127.0.0.1:47913/base//webhook/mcp/events/webhook/abc
Expected
POST http://127.0.0.1:47913/base/webhook
POST http://127.0.0.1:47913/base/webhook/mcp/events/webhook/abc
Cause
pkg/listen/proxy/proxy.go:395:
url := p.cfg.URL.Scheme + "://" + p.cfg.URL.Host + p.cfg.URL.Path + webhookEvent.Body.PathTrimming a trailing / from p.cfg.URL.Path before appending would fix it. path.Join would also drop a trailing slash from the event's own path, which a receiver may route on.
Related, from the same line (code reading, not tested)
Only the scheme, host and path of the forwarding URL are used, so a query string on it (for example http://localhost:3000/hook?token=x) is dropped without a warning. Forwarding it, or refusing it at startup, would avoid a silent difference.
Activity
test(listen): stop asserting that a query string on the forwarding UR…