Skip to content

fix(cli): honor --db-url sslmode - #5980

Merged
Coly010 merged 3 commits into
supabase:developfrom
7ttp:fix/db-url-sslmode-round-trip-5873
Jul 29, 2026
Merged

fix(cli): honor --db-url sslmode#5980
Coly010 merged 3 commits into
supabase:developfrom
7ttp:fix/db-url-sslmode-round-trip-5873

Conversation

@7ttp

@7ttp 7ttp commented Jul 28, 2026

Copy link
Copy Markdown
Member

TL;DR

sslmode from --db-url never reached the connection PGSSLMODE and libpq's prefer default decided TLS instead....

Problem

pgconn.ParseConfig folds sslmode into TLSConfig/Fallbacks, but ToPostgresURL serialises only RuntimeParams, so ConnectByConfigStream's round-trip drops it.

--db-url before after
?sslmode=require + PGSSLMODE=disable plaintext TLS
?sslmode=disable forced to TLS-only plaintext
?sslmode=verify-full vs untrusted cert accepted rejected

Solution

Replay the TLS state pgconn already resolved instead of round-tripping it through a string. Code-assembled configs (local, linked, proxy) have a nil Fallbacks slice, which ParseConfig never produces, so they keep libpq's defaults.

TS already behaves this way; this brings the go-cli to parity for the commands still routed thru it...

Ref

@7ttp
7ttp requested a review from a team as a code owner July 28, 2026 23:31
@7ttp 7ttp self-assigned this Jul 28, 2026
@7ttp

7ttp commented Jul 28, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3cfb4d401b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/cli-go/internal/utils/connect.go
Comment thread apps/cli-go/internal/utils/connect.go Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 070775c56f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/cli-go/internal/utils/connect.go
@7ttp

7ttp commented Jul 29, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 20c86fb934

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@Coly010
Coly010 added this pull request to the merge queue Jul 29, 2026
Merged via the queue into supabase:develop with commit a08aa7b Jul 29, 2026
37 checks passed
pull Bot pushed a commit to oogalieboogalie/cli that referenced this pull request Jul 29, 2026
## TL;DR

`--debug` silently disabled TLS on every database connection

## Problem

`debug.SetupPGX` nulled `config.TLSConfig` so
its wirelogging proxy could read plaintext frames. It runs after sslmode
resolution, so `--debug` overrode an explicit `?sslmode=require` with no
warning, sent the session unencrypted, and failed with `no pg_hba.conf
entry ... no encryption` on SSL-enforcing projects that worked fine
without the flag.

Still live on the TS shell:
which forwards `--debug` to the Go binary for `migration squash`, `db
test`, `db remote commit|changes` and bootstrap's push step.

## Sol:

The proxy now does libpq's SSLRequest handshake itself with the
`tls.Config` pgx resolved,
then hands pgx an in-memory pipe. It has to own TLS because `DialFunc`
sits below it, which is why the original just nulled it.

Frames decrypt in process, the socket stays encrypted, verification is
unchanged, and a refusal fails the dial instead of continuing in
plaintext....

Also drops the now false `SSL connection is not supported with --debug
flag` hint from both shells.
It was never true in TS, where `--debug` has never disabled TLS.

## Ref

- Fixes supabase#5872
- Related supabase#5873 via supabase#5980
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.

sslmode from --db-url is dropped when the connection config is round-tripped through ToPostgresURL()

2 participants