Skip to content

RootRequestBuilder sends GET /%2F instead of GET / (slash path segment is percent-encoded) #799

Closed

Description

@bsomuncuoglu-circle

Summary

RootRequestBuilder requests the Horizon root endpoint as GET /%2F rather than GET /. The "/" passed as a path segment is percent-encoded by OkHttp to %2F, so the outgoing request path is /%2F.

Most Horizon servers normalize /%2F to / and return 200, so this has gone unnoticed. However, servers/proxies with stricter path routing return 404 for /%2F, which causes root requests (e.g. Server.root() used during network-passphrase validation) to fail.

Where it comes from

RootRequestBuilder is constructed with "/" as a path segment:

// src/main/java/org/stellar/sdk/requests/RootRequestBuilder.java
public RootRequestBuilder(OkHttpClient httpClient, HttpUrl serverURI) {
  super(httpClient, serverURI, "/");
}

That segment is then added in RequestBuilder.buildUri():

// src/main/java/org/stellar/sdk/requests/RequestBuilder.java
HttpUrl buildUri() {
  if (!segments.isEmpty()) {
    for (String segment : segments) {
      uriBuilder.addPathSegment(segment);   // addPathSegment("/") -> encodes to %2F
    }
  }
  return uriBuilder.build();
}

OkHttp's addPathSegment("/") treats "/" as a single literal segment and percent-encodes the reserved / character to %2F, producing a request path of /%2F.

Reproduction

Against a server that does not normalize %2F:

$ curl -o /dev/null -s -w '%{http_code}\n' https://<horizon-host>/%2F
404
$ curl -o /dev/null -s -w '%{http_code}\n' https://<horizon-host>/
200

A native Horizon node (tested against horizon 26.0.0) returns 200 for both / and /%2F, which is why the encoded path normally works. A stricter endpoint returns 404 only for /%2F.

Impact

When the backing RPC/Horizon endpoint stops tolerating /%2F, every RootRequestBuilder.execute() call returns 404. In our case this broke client startup paths that validate the network passphrase via the root endpoint.

Versions

Verified identical in 2.1.0, 2.2.3, and 3.0.0 (latest stable) — same RootRequestBuilder constructor (super(httpClient, serverURI, "/")) and buildUri() addPathSegment(segment) loop in all three.

Activity

  1. overcat commented on Jun 11, 2026

    @overcat
    Member

    Thank you for reporting this issue, we will release v3.1.0 tomorrow to solve this problem.

  2. overcat commented on Jun 12, 2026

    @overcat
    Member

    Fixed in v3.1.0

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