You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(service): merge sslmode params into one connection setting so host survives (#694)
A non-`unset` Postgres TLS mode dropped the `host`/`port`/`dbname` params and
libpq fell back to the local Unix socket, so `DB_SSL_MODE=require` (and every
verifying mode) failed to start against a remote host -- the documented
ADR-0064 / #684 TLS-hardening path and the Azure Flexible Server golden path.
Root cause: `toConnectionParams` emitted the base params and each TLS param as
SEPARATE `Hasql.Connection.Setting.connection` values. hasql's
`staticConnectionSettings` applies each one by REPLACING the whole connection
string (`setConnectionString config {connectionString}` folded left -- last
wins, not merge), so the `sslmode`-only setting wiped out host/port/dbname.
`SslModeUnset` emitted no TLS setting, which is why only the unset path worked.
Fix: build every libpq param -- base AND conditional TLS -- into ONE
`ConnectionSettingConnection.params [...]`, i.e. a single `connection` Setting.
The three pools (EventStore, FileUpload, QueryObjectStore) all route through
this builder, so all three are fixed. The `unset` path stays byte-identical
(same 9 params in one setting), preserving the ADR-0064 §2 no-regression
guarantee.
To make the contract testable after collapsing to one opaque setting, the param
set is now produced as an inspectable `toParamPairs :: ... -> LinkedList
(Text, Text)` (the hasql Param/Setting types have no Eq/Show and their rendering
modules are internal). Tests assert directly that `host` survives every sslMode
and that no `sslcert`/`sslkey` ever leaks in (ADR-0064 §3).
Tests:
- ConnectionConfigSpec: new #694 regression (exactly ONE connection setting for
every sslMode) + `toParamPairs` host-survival and exact-param-set assertions,
replacing the prior length-based ssl tests that encoded the multi-setting
structure. Verified red: reintroducing the split setting yields 2 settings for
`require` / 4 for `verify-full`+cert and fails the regression.
- FileUpload FileStateStore PostgresSpec: the `#684` sslMode-threading test that
asserted `Ok 2` settings (the buggy shape) now asserts `Ok 1` and verifies the
`sslmode=require` param via `toParamPairs`.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
0 commit comments