Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(config): stop .env.example pinning five dashboard-owned keys
Yudhi Armyndharisf3d51bca7a84
diff --git a/.env.example b/.env.exampleindex 8282608a4..45fd70520 100644--- a/.env.example+++ b/.env.example@@ -271,7 +271,7 @@ BAILEYS_AUTH_DIR=./data/baileys# =============================================================================# Options: sqlite, postgres# DATABASE_TYPE=sqlite-POSTGRES_BUILTIN=false # Use built-in PostgreSQL container?+# POSTGRES_BUILTIN=false # Use built-in PostgreSQL container?# PostgreSQL settings (ignored for sqlite, auto-configured if POSTGRES_BUILTIN=true)# DATABASE_HOST=localhost@@ -298,8 +298,8 @@ DATABASE_SYNCHRONIZE=false # WARNING: Set false in production! (data DB# Set to "false" to manage the api_keys/audit_logs schema via the bundled main-owned# migration instead of synchronize (migrationsRun creates them at boot).# MAIN_DATABASE_SYNCHRONIZE=true-DATABASE_SSL=false # Set true for managed Postgres (Supabase, Heroku, Render, Railway)-DATABASE_SSL_REJECT_UNAUTHORIZED=true # Set false to allow self-signed certs (only when DATABASE_SSL=true)+# DATABASE_SSL=false # Set true for managed Postgres (Supabase, Heroku, Render, Railway)+# DATABASE_SSL_REJECT_UNAUTHORIZED=true # Set false to allow self-signed certs (only when DATABASE_SSL=true)# PostgreSQL connection pool size.# DATABASE_POOL_SIZE=10# Postgres pool/query timeouts (ms). Defaults are conservative; set any to 0 to disable.@@ -314,7 +314,7 @@ DATABASE_CONNECTION_TIMEOUT_MS=10000 # Fails fast if a new connection can't be a# event fan-out (Socket.IO Redis adapter). Multi-replica# deployments need this so a WS client on one replica receives# events raised on another; single-node can leave it off.-REDIS_BUILTIN=false # Use built-in Redis container?+# REDIS_BUILTIN=false # Use built-in Redis container?# Process webhooks/ingress through the BullMQ queue (needs a reachable Redis via REDIS_HOST/REDIS_PORT).# Off by default (inline dispatch). In the bundled Docker Compose this is dashboard-managed# (Infrastructure > Redis & Queue) — a host value here is not forwarded to the container.@@ -335,7 +335,7 @@ REDIS_CONNECT_TIMEOUT_MS=5000# =============================================================================# Options: local, s3# STORAGE_TYPE=local-MINIO_BUILTIN=false # Use built-in MinIO container?+# MINIO_BUILTIN=false # Use built-in MinIO container?# Local storage path (if STORAGE_TYPE=local)# STORAGE_LOCAL_PATH=./data/mediadiff --git a/CHANGELOG.md b/CHANGELOG.mdindex 93416746e..4a05dac7c 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -9,10 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0### Added-- ⚠️ **Breaking (config).** `NODE_ENV` is checked at boot, so a value outside `production`, `development` and `test` fails startup with a named error instead of silently selecting the permissive branch of every production hardening — CORS, Swagger, DTO error detail, the default-secret guard and the `ALLOW_DEV_API_KEY` rejection that stops the public `dev-admin-key` being seeded as an ADMIN credential. The value is compared verbatim, so a padded ` production ` is rejected too: every reader compares the raw variable. Action required: a deployment running `NODE_ENV=staging` (or any other value) now refuses to boot where it previously started with development-grade security. Set `production`, or leave the variable unset. Unset remains legal and unchanged.+- ⚠️ **Breaking (config).** `NODE_ENV` is checked at boot, so a value outside `production`, `development` and `test` fails startup with a named error instead of silently selecting the permissive branch of every production hardening — CORS, Swagger, DTO error detail, the default-secret guard and the `ALLOW_DEV_API_KEY` rejection that stops the public `dev-admin-key` being seeded as an ADMIN credential. The value is compared verbatim, so one padded with surrounding whitespace is rejected too rather than accepted and then treated as non-production: every reader compares the raw variable. Action required: a deployment running `NODE_ENV=staging` (or any other value) now refuses to boot where it previously started with development-grade security. Set `production`, or leave the variable unset. Unset remains legal and unchanged.### Fixed+- `.env.example` shipped five keys the Infrastructure dashboard owns — `POSTGRES_BUILTIN`, `DATABASE_SSL`, `DATABASE_SSL_REJECT_UNAUTHORIZED`, `REDIS_BUILTIN` and `MINIO_BUILTIN` — uncommented, so an operator who followed the documented `cp .env.example .env` pinned them: the dashboard control still saved and reported success while the running value never changed, most consequentially leaving a Postgres connection unencrypted after the operator enabled SSL. The file's own header already promised a gate against this, but that gate only reached keys docker-compose forwards blank; it now covers every key the dashboard writes.+- Two enabled instances of one integration plugin that share a session scope no longer collapse onto a single config, so an ingress delivery authenticated with one instance's secret is no longer handled with the credentials of whichever instance was provisioned last. Dispatch now layers the instance's own config over the base config and any per-session override.## [0.17.0] - 2026-08-12diff --git a/src/config/env-precedence.spec.ts b/src/config/env-precedence.spec.tsindex 659b89c07..c27929857 100644--- a/src/config/env-precedence.spec.ts+++ b/src/config/env-precedence.spec.ts@@ -258,3 +258,44 @@ describe.each(['docker-compose.yml', 'docker-compose.dev.yml'])('every blank forexpect(uncommented.filter(key => blankForwards().includes(key))).toEqual([]);});});++/**+ * The rule above binds only the keys compose forwards blank. `.env.example`'s own header promises+ * something wider — "every setting the dashboard owns is commented out" — and the dashboard owns+ * keys that have no blank forward at all (DATABASE_SSL, POSTGRES_BUILTIN, REDIS_BUILTIN,+ * MINIO_BUILTIN, DATABASE_SSL_REJECT_UNAUTHORIZED, DATABASE_POOL_SIZE, REDIS_PASSWORD). Those slipped+ * past the compose-derived check and shipped uncommented, pinning the matching Infrastructure control+ * for anyone who ran the documented `cp .env.example .env`.+ *+ * Derived from the appliers that write data/.env.generated, so a key added to a section is covered+ * without anyone remembering this file exists.+ */+describe('every key the dashboard writes is commented out in .env.example', () => {+ const sectionsSource = fs.readFileSync(path.join(__dirname, '../modules/infra/config-sections.ts'), 'utf8');++ /** `updates.KEY = …` */+ const directlyAssigned = (): string[] => [...sectionsSource.matchAll(/updates\.([A-Z0-9_]+)\s*=/g)].map(m => m[1]);+ /** `setSecret(updates, 'KEY', …)` — an indirection the direct form cannot see. */+ const viaSecretHelper = (): string[] =>+ [...sectionsSource.matchAll(/setSecret\(\s*updates\s*,\s*'([A-Z0-9_]+)'/g)].map(m => m[1]);++ const dashboardOwned = (): string[] => [...new Set([...directlyAssigned(), ...viaSecretHelper()])].sort();++ // Guard both extractors independently. The direct form alone finds 27 keys and silently misses+ // every key routed through setSecret, so a single combined count would look healthy while the+ // secret keys went unchecked.+ it('extracts keys from both write forms', () => {+ expect(directlyAssigned()).toContain('DATABASE_SSL');+ expect(viaSecretHelper()).toContain('REDIS_PASSWORD');+ });++ it('ships none of them uncommented', () => {+ const example = fs.readFileSync(path.join(__dirname, '../../.env.example'), 'utf8');+ const uncommented = example+ .split('\n')+ .map(line => /^([A-Z0-9_]+)=/.exec(line)?.[1])+ .filter((key): key is string => key !== undefined);+ expect(uncommented).toContain('NODE_ENV'); // the file really does ship some keys uncommented+ expect(uncommented.filter(key => dashboardOwned().includes(key))).toEqual([]);+ });+});