8000 listen: a trailing slash on the forwarding URL produces // in the forwarded path · Issue #475 · hookdeck/hookdeck-cli · GitHub
[go: up one dir, main page]

Skip to content

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

Open

Description

@leggetter

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-cli 3.1.0 (Homebrew), macOS
  • An Event Gateway project; a source with a connection to a CLI destination whose path is /webhook

Steps to reproduce

  1. Forward to a URL with a trailing slash:

    hookdeck listen http://127.0.0.1:47913/base/ <source> --output compact
  2. 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.Path

Trimming 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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0