fix(worker): handle Unix-socket PGHOST in connection URL (#266)#292
Merged
Conversation
tjgreen42
force-pushed
the
tjgreen42/fix-pghost-socket-url
branch
from
July 17, 2026 03:49
bfcd33c to
fb98be4
Compare
tjgreen42
marked this pull request as ready for review
July 17, 2026 03:54
postgres_connection_string() built a postgres://user@host:port/db URL with PGHOST as the host. A Unix-socket directory PGHOST (e.g. CloudNativePG's /controller/run) put a raw path in the URL authority, which the parser rejects as "empty host", so the worker never connected and instances stayed pending. build_connection_url() percent-encodes a socket-path host (one starting with /) with the NON_ALPHANUMERIC set sqlx uses in its own build_url(). sqlx percent-decodes it and connects over the socket; encoding the whole path keeps the directory opaque, so metacharacters cannot be reinterpreted as a TCP host or query parameters. TCP addresses and hostnames are used verbatim. get_host()/connect_as_user() already handle socket paths via PgConnectOptions::host(). Tests cover TCP, hostname, and socket-directory inputs, including paths with a space and URL metacharacters, asserting the URL parses to the expected socket/host via sqlx. Copilot-Session: b5f8cc43-8ac2-4355-90c8-18a10d488296
tjgreen42
force-pushed
the
tjgreen42/fix-pghost-socket-url
branch
from
July 17, 2026 04:02
fb98be4 to
bf0e81a
Compare
tjgreen42
marked this pull request as draft
July 17, 2026 04:04
tjgreen42
marked this pull request as ready for review
July 17, 2026 04:06
affandar
approved these changes
Jul 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Percent-encode a Unix-socket
PGHOST(one starting with/) when building the worker'spostgres://connection URL so sqlx connects over the socket. TCP addresses and hostnames are unchanged.get_host()/connect_as_user()need no change:PgConnectOptions::host()already handles socket paths.Adds unit tests for TCP, hostname, and socket-directory inputs.
Fixes #266.