From 171f21b99bee1868fee754853f308efae6768f69 Mon Sep 17 00:00:00 2001 From: Julien Gautier Date: Fri, 8 May 2026 23:13:17 +0200 Subject: [PATCH] fix(infra): pass pgweb credentials via discrete CLI flags (#63) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary `PGWEB_DATABASE_URL` (post-#62 rename) still fails at boot: ``` Error: Invalid URL. Valid format: postgres://user:password@host:port/db?sslmode=mode ``` Root cause: the userinfo portion of a Postgres URL must be URL-encoded — any `@`, `#`, `:`, `/`, `?`, `%`, `&`, `=`, `+`, `;` etc. in the password breaks the parser. Compose has no built-in URL encoding, so the URL we construct in YAML is fragile by design and depends on the developer happening to pick a URL-safe password. Switch to pgweb's discrete CLI flags (`--host`, `--port`, `--user`, `--pass`, `--db`, `--ssl`). Compose interpolates each value literally — no URL encoding required, any password works. The image's ENTRYPOINT already passes `--bind=0.0.0.0 --listen=8081`; our args are appended to those. ## Side benefit A missing password now yields an explicit Compose error (`POSTGRES_PASSWORD must be set in infra/local/.env`) rather than an opaque pgweb crash with a vague "Invalid URL" message. ## Test plan - [ ] After merge: `docker compose -f infra/local/dev.compose.yml --profile dbtools up -d` → pgweb stays up (no `Restarting (1)` loop). - [ ] http://localhost:8081 loads pgweb's UI; you can navigate to the `audit` schema. - [ ] Confirm with a password that contains a special char (e.g., `dev@pass#2026!`) — should still work. --------- Co-authored-by: Julien Gautier Reviewed-on: https://git.unespace.com/julien/apf_portal/pulls/63 --- infra/local/dev.compose.yml | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/infra/local/dev.compose.yml b/infra/local/dev.compose.yml index f281c23..5af93b8 100644 --- a/infra/local/dev.compose.yml +++ b/infra/local/dev.compose.yml @@ -102,11 +102,20 @@ services: container_name: apf-portal-pgweb restart: unless-stopped profiles: [dbtools] - environment: - # `PGWEB_DATABASE_URL` (formerly `DATABASE_URL`) — pgweb 0.16 - # deprecated the old name, ignores it, and starts up empty, - # crashing with "Invalid URL". - PGWEB_DATABASE_URL: postgres://${POSTGRES_USER:-portal}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-portal_dev}?sslmode=disable + # Use discrete CLI flags rather than `PGWEB_DATABASE_URL`. The URL + # form is fragile: any special character in POSTGRES_PASSWORD + # (`@`, `#`, `:`, `/`, `?`, `%`, `&`, …) breaks the userinfo + # parser, and the resulting "Invalid URL" error is opaque. Discrete + # flags accept any password verbatim. The image's ENTRYPOINT + # already passes `--bind=0.0.0.0 --listen=8081`; these args are + # appended. + command: + - --host=postgres + - --port=5432 + - --user=${POSTGRES_USER:-portal} + - --pass=${POSTGRES_PASSWORD:?POSTGRES_PASSWORD must be set in infra/local/.env} + - --db=${POSTGRES_DB:-portal_dev} + - --ssl=disable ports: - '${PGWEB_PORT:-8081}:8081' depends_on: