ipfs/kubo · error

invalid request path '%s'

Error message

invalid request path '%s'

What it means

The libp2p HTTP proxy gateway could not parse the request URL into peer ID, protocol name and inner HTTP path. It fires when the path has too few segments or the peer-ID segment does not decode, i.e. it does not match /p2p/<peerid>/http/<path> or /p2p/<peerid>/x/<proto>/http/<path>.

Source

Thrown at core/corehttp/p2p_proxy.go:66

	}
}

type proxyRequest struct {
	target   string
	name     protocol.ID
	httpPath string // path to send to the proxy-host
}

// from the url path parse the peer-ID, name and http path
// /p2p/$peer_id/http/$http_path
// or
// /p2p/$peer_id/x/$protocol/http/$http_path
func parseRequest(request *http.Request) (*proxyRequest, error) {
	path := request.URL.Path

	split := strings.SplitN(path, "/", 5)
	if len(split) < 5 {
		return nil, fmt.Errorf("invalid request path '%s'", path)
	}

	if _, err := peer.Decode(split[2]); err != nil {
		return nil, fmt.Errorf("invalid request path '%s'", path)
	}

	if split[3] == "http" {
		return &proxyRequest{split[2], protocol.ID("/http"), split[4]}, nil
	}

	split = strings.SplitN(path, "/", 7)
	if len(split) < 7 || split[3] != "x" || split[5] != "http" {
		return nil, fmt.Errorf("invalid request path '%s'", path)
	}

	return &proxyRequest{split[2], protocol.ID("/x/" + split[4] + "/http"), split[6]}, nil
}

View on GitHub (pinned to 329838acdf)

Solutions

  1. Use the documented forms: /p2p/<peerID>/http/<path> or /p2p/<peerID>/x/<protocol>/http/<path>
  2. Verify the peer ID segment is a valid multibase peer ID (starts with 12D3KooW, Qm..., etc.)
  3. Ensure the listener was started with 'ipfs p2p listen' or that the target peer supports the protocol
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at core/corehttp/p2p_proxy.go:66 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03). Data as JSON: /api/errors/3d42d9ddf576cdaf. Report an issue: GitHub.