Skip to content

Conversation

@rileytomasek
Copy link

Fixes a bug where the HTTP client fails against databases/branches whose names contain / (such as preview/pr-662 or dev/riley) because the database identifier is interpolated directly into /db/${database}/... URLs without encoding, causing the server to interpret / as path separators and return 404.

Changes

  • In packages/gel/src/utils.ts#getAuthenticatedFetch, percent-encode the database/branch identifier before constructing the /db/... URL:
    • Build baseUrl from protocol and address as before.
    • Compute encodedDatabase = encodeURIComponent(database).
    • Build databaseUrl using encodedDatabase for the /db/${encodedDatabase}/... path segment.
  • Add a regression test to packages/gel/test/client.test.ts (under the existing binary-over-http feature gate) that:
    • Stubs globalThis.fetch.
    • Calls getAuthenticatedFetch with database: "preview/pr-662" and valid connection options.
    • Invokes the returned authenticatedFetch.
    • Asserts that the request URL pathname is /db/preview%2Fpr-662/.
    • Restores the original globalThis.fetch.

Rationale

  • Aligns the HTTP client behavior with the CLI/binary clients, which support any valid branch/database name including those containing /.
  • Prevents subtle 404s when applications use per-branch names like dev/<user> or preview/pr-<number> with the HTTP client.
  • Does not change the public API surface; only fixes URL construction.

Testing

Locally (against the rileytomasek/gel-js fork):

  • yarn install --frozen-lockfile
  • yarn turbo run typecheck --filter=gel (pass)
  • yarn turbo run lint --filter=gel (pass)
  • yarn turbo run test --filter=gel
    • Fails in this environment at Jest globalSetup because the Gel/EdgeDB server binary (GEL_SERVER_BIN / edgedb-server) is not available.
    • In CI or a dev environment where the Gel server binary is configured, the updated test suite should run and cover the new regression test.

Fixes #1320.

@gel-data-cla
Copy link

gel-data-cla bot commented Nov 8, 2025

The following commit authors need to sign the Contributor License Agreement:

Click the button to sign:
CLA not signed

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.

HTTP client: branch names containing / cause 404 due to unencoded /db/${branch}/… URLs

2 participants