Skip to content

fix(config): bracket an IPv6 database host in the assembled DSN - #834

Open
hakarrr wants to merge 2 commits into
BaaRai:mainfrom
hakarrr:fix-pg-ipv6-dsn
Open

hakarrr wants to merge 2 commits into
BaaRai:mainfrom
hakarrr:fix-pg-ipv6-dsn

Conversation

@hakarrr

@hakarrr hakarrr commented Dec 2, 2026

Copy link
Copy Markdown

Problem

When the DSN is assembled from database.host / ARTEX_PG_HOST, the host and port were joined as host + ":" + port. A bare IPv6 address such as ::1 or 2001:db8::5 gave postgres://u@::1:5432/db, which does not parse as a URL, so ARTEX could not connect to a PostgreSQL server on an IPv6 address. Only a host typed as [::1] worked.

Behavior change

The authority is built with net.JoinHostPort, after removing any brackets the operator typed. Hostnames and IPv4 addresses produce the same DSN as before. An explicit ARTEX_PG_DSN is still returned unchanged.

Tested

config/dsn_host_test.go builds a DSN for an empty host, a hostname, IPv4, bare IPv6 and bracketed IPv6, parses it with pgx (pgconn.ParseConfig) and checks the host and port pgx reads (before the change pgx read host ::1:5432 for ::1). The bare IPv6 cases fail before the change. go test ./config, gofmt and go vet pass.

hakarrr and others added 2 commits December 2, 2026 17:46
Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
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.

1 participant