#2667·pgx

pgconn.ParseConfig has backward incompatible changes between 5.10 and 5.11

Author: mathew-cinnamonCreated Sep 30, 2026Updated Sep 30, 2026
Labelsbug

Bug description

Connection string parsing does not maintain backward compatibility between v5.10 and v5.11 when passing a naively formatted connection string.

To Reproduce

Run this using v5.10 and then v5.11

go
package main

import (
	"fmt"
	"log"

	"github.com/jackc/pgx/v5/pgconn"
)

func main() {
	const (
		dbName = "testdb"
		dbUser = "testuser"
		dbPass = "9@HASH426ahdhj2Hca@!@"
		host   = "localhost"
		port   = "5432"
	)

	connStr := fmt.Sprintf("postgres://%s:%s@%s:%s/%s", dbUser, dbPass, host, port, dbName)
	cfg, err := pgconn.ParseConfig(connStr)
	if err != nil {
		log.Fatalf("failed to parse config: %s", err)
	}
	if cfg.Host != host {
		log.Fatalf("given and parsed host are different: given=%s, parsed=%s", host, cfg.Host)
	}
}

Expected behavior Both versions should continue to parse this string in the same way.

Actual behavior v5.11 returns a host with part of the password concatenated.

Version

  • Go: go version go1.27.1 darwin/arm64
  • PostgreSQL: N/A
  • pgx: v5.11.0

Additional context The following works:

go
connStr := fmt.Sprintf("postgres://%s:%s@%s:%s/%s", dbUser, dbPass, host, port, dbName)
u,  _ := url.Parse(connStr)
cfg, err := pgconn.ParseConfig(u.String())
...

I'm not sure if this counts as backward incompatibility since it is due to a naively formatted connection string, but I did want to bring it up.