Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(compose): forward the flags a .env value could not otherwise reach

Yudhi Armyndharisd6a18735588b
diff --git a/.env.example b/.env.example
index 2d1b8c054..824f761e6 100644
--- a/.env.example
+++ b/.env.example
@@ -165,13 +165,13 @@ BAILEYS_AUTH_DIR=./data/baileys
# POST /api/sessions (whatsapp-web.js engine only), NOT via environment variables.
# Pull the FULL message-history archive on connect (large). Off by default: the engine still enables the
# initial sync (contacts, chats, recent messages, lid mappings) without downloading the entire history.
-BAILEYS_SYNC_FULL_HISTORY=false
+# BAILEYS_SYNC_FULL_HISTORY=false
# Announce the linked device as online when the socket connects. Baileys' default is true, which
# suppresses WhatsApp push notifications on the paired phone while the gateway is connected —
# a 24/7 gateway then silences the phone permanently (#871). Set to false to keep phone
# notifications working. Only gates the on-connect presence: the typing / chat-state send API
# still announces per-chat presence for that call.
-BAILEYS_MARK_ONLINE_ON_CONNECT=true
+# BAILEYS_MARK_ONLINE_ON_CONNECT=true
# Device name shown in WhatsApp Settings → Linked Devices for NEW pairings (existing sessions keep
# the name they were paired with until re-linked). Default: OpenWA.
# BAILEYS_BROWSER_NAME=
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 54522abb2..fb094a349 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+### Fixed
+
+- **Seven settings that did nothing under Docker now take effect** — Compose forwards environment explicitly and has no `env_file`, so `BAILEYS_MARK_ONLINE_ON_CONNECT`, `BAILEYS_SYNC_FULL_HISTORY`, `WEBHOOK_CONTACT_DETAILS`, `ALLOW_UNSIGNED_INGRESS`, `STORE_EPHEMERAL_MESSAGES`, `RESOLVE_LID_TO_PHONE` and `SIMULATE_TYPING` never reached the container however the operator's `.env` was written; the first of those left the paired phone's notifications suppressed for as long as the gateway stayed connected.
+
### Changed
- **Fourteen more boolean environment variables are now validated at boot** — they are read with a bare `=== 'true'` / `!== 'false'` comparison, so a spelling like `DATABASE_SSL=require` silently configured the opposite of what was asked for; `DATABASE_SSL` in particular read as OFF and sent credentials in plaintext to a server the operator believed was TLS-protected. Only `true`/`false` (or blank) are accepted now, so a deployment using another spelling will fail startup until it is corrected. `MCP_READONLY` and `PUPPETEER_HEADLESS` stay tolerant deliberately — both fail toward the safe state.
diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml
index 6e7da8f68..d294e69e0 100644
--- a/docker-compose.dev.yml
+++ b/docker-compose.dev.yml
@@ -89,6 +89,15 @@ services:
- WEBHOOK_RETRY_DELAY=${WEBHOOK_RETRY_DELAY:-5000}
- WEBHOOK_DISPATCH_CONCURRENCY=${WEBHOOK_DISPATCH_CONCURRENCY:-16}
- WEBHOOK_DISPATCH_MAX_QUEUED=${WEBHOOK_DISPATCH_MAX_QUEUED:-1000}
+ # Mirrors docker-compose.yml: flags with no dashboard route, which a .env value could not
+ # otherwise reach the container at all.
+ - WEBHOOK_CONTACT_DETAILS=${WEBHOOK_CONTACT_DETAILS:-}
+ - BAILEYS_MARK_ONLINE_ON_CONNECT=${BAILEYS_MARK_ONLINE_ON_CONNECT:-}
+ - BAILEYS_SYNC_FULL_HISTORY=${BAILEYS_SYNC_FULL_HISTORY:-}
+ - ALLOW_UNSIGNED_INGRESS=${ALLOW_UNSIGNED_INGRESS:-}
+ - STORE_EPHEMERAL_MESSAGES=${STORE_EPHEMERAL_MESSAGES:-}
+ - RESOLVE_LID_TO_PHONE=${RESOLVE_LID_TO_PHONE:-}
+ - SIMULATE_TYPING=${SIMULATE_TYPING:-}
- RATE_LIMIT_SHORT_TTL=${RATE_LIMIT_SHORT_TTL:-}
- RATE_LIMIT_SHORT_LIMIT=${RATE_LIMIT_SHORT_LIMIT:-}
- RATE_LIMIT_MEDIUM_TTL=${RATE_LIMIT_MEDIUM_TTL:-}
diff --git a/docker-compose.yml b/docker-compose.yml
index 138a40be4..fb9fb69fa 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -219,6 +219,17 @@ services:
- WEBHOOK_RETRY_DELAY=${WEBHOOK_RETRY_DELAY:-5000}
- WEBHOOK_DISPATCH_CONCURRENCY=${WEBHOOK_DISPATCH_CONCURRENCY:-16}
- WEBHOOK_DISPATCH_MAX_QUEUED=${WEBHOOK_DISPATCH_MAX_QUEUED:-1000}
+ # Flags the app reads with a bare `=== 'true'` / `!== 'false'` and that have no dashboard
+ # route, so without these forwards setting them in .env does nothing under compose.
+ # BAILEYS_MARK_ONLINE_ON_CONNECT is the one that bites: its default silences push
+ # notifications on the paired phone for as long as the gateway is connected (#871).
+ - WEBHOOK_CONTACT_DETAILS=${WEBHOOK_CONTACT_DETAILS:-}
+ - BAILEYS_MARK_ONLINE_ON_CONNECT=${BAILEYS_MARK_ONLINE_ON_CONNECT:-}
+ - BAILEYS_SYNC_FULL_HISTORY=${BAILEYS_SYNC_FULL_HISTORY:-}
+ - ALLOW_UNSIGNED_INGRESS=${ALLOW_UNSIGNED_INGRESS:-}
+ - STORE_EPHEMERAL_MESSAGES=${STORE_EPHEMERAL_MESSAGES:-}
+ - RESOLVE_LID_TO_PHONE=${RESOLVE_LID_TO_PHONE:-}
+ - SIMULATE_TYPING=${SIMULATE_TYPING:-}
# Rate limits. Blank values are cleared before lower-priority generated config is loaded.
- RATE_LIMIT_SHORT_TTL=${RATE_LIMIT_SHORT_TTL:-}
- RATE_LIMIT_SHORT_LIMIT=${RATE_LIMIT_SHORT_LIMIT:-}
diff --git a/src/config/env-precedence.ts b/src/config/env-precedence.ts
index ea8b3f66a..5cb4a98dc 100644
--- a/src/config/env-precedence.ts
+++ b/src/config/env-precedence.ts
@@ -75,6 +75,16 @@ export const BLANK_SHADOWED_ENV_KEYS: string[] = [
// Autoreply rule cap, blank-forwarded like the knobs above so an operator who sets nothing does
// not have an empty string shadow a value in .env / data/.env.generated.
'AUTOMATION_MAX_PER_SESSION',
+ // Behaviour flags with no dashboard route: before they were forwarded, a value set in .env simply
+ // never reached the container. They are blank-forwarded like everything else here so the forward
+ // itself cannot pin them off.
+ 'WEBHOOK_CONTACT_DETAILS',
+ 'BAILEYS_MARK_ONLINE_ON_CONNECT',
+ 'BAILEYS_SYNC_FULL_HISTORY',
+ 'ALLOW_UNSIGNED_INGRESS',
+ 'STORE_EPHEMERAL_MESSAGES',
+ 'RESOLVE_LID_TO_PHONE',
+ 'SIMULATE_TYPING',
// Redis selection + connection details (#488)
'REDIS_ENABLED',
'REDIS_HOST',
diff --git a/src/modules/docker/compose-parity.spec.ts b/src/modules/docker/compose-parity.spec.ts
index 00b811841..84aa19d9d 100644
--- a/src/modules/docker/compose-parity.spec.ts
+++ b/src/modules/docker/compose-parity.spec.ts
@@ -258,6 +258,65 @@ describe('DockerService managed specs ↔ docker-compose.yml parity', () => {
expect(read.filter(name => !forwarded.has(name))).toEqual([]);
});
+ // The family test above only covers three prefixes, so a boolean flag outside them could be added
+ // to the app and never forwarded — setting it in .env then does nothing under compose, silently.
+ // env-precedence.spec.ts cannot catch it either: that suite derives its expectations FROM the
+ // compose files, so it is structurally blind to a flag compose omits. This is the code -> compose
+ // direction, derived from env.validation.ts's checkBool list, which already enumerates every flag
+ // read with a bare `=== 'true'` / `!== 'false'` and carries a written rationale per key.
+ it('forwards every strict boolean flag, or names it in the not-forwarded allowlist', () => {
+ // Deliberately NOT forwarded. Each entry states why, so adding a key here is a decision rather
+ // than an omission.
+ const NOT_FORWARDED: Record<string, string> = {
+ // Owned by the dashboard's Infrastructure page, which writes data/.env.generated on the mounted
+ // volume — that file IS read inside the container, so these are settable, just not via .env.
+ POSTGRES_BUILTIN: 'dashboard-managed',
+ REDIS_BUILTIN: 'dashboard-managed',
+ MINIO_BUILTIN: 'dashboard-managed',
+ DATABASE_SSL: 'dashboard-managed',
+ DATABASE_SSL_REJECT_UNAUTHORIZED: 'dashboard-managed',
+ QUEUE_ENABLED: 'dashboard-managed',
+ // A typo or an absent value leaves these at the SECURE / documented-default state, so not
+ // forwarding them cannot degrade a deployment.
+ WEBHOOK_SSRF_PROTECT: 'fails safe (default on)',
+ ALLOW_DEV_API_KEY: 'refused outright in production',
+ // MCP_READONLY is deliberately absent: env.validation.ts leaves it out of the strict list on
+ // purpose (mcp.server.spec.ts asserts 'yes' keeps read-only on), so it is not in scope here.
+ // Pre-existing and not yet reviewed: these are module-level or diagnostic toggles that an
+ // operator currently cannot set under compose. Listed so the gate is honest about them rather
+ // than silently green; each needs its own decision before being forwarded.
+ MCP_ENABLED: 'pending review',
+ SEARCH_ENABLED: 'pending review',
+ SERVE_DASHBOARD: 'pending review',
+ CACHE_ENABLED: 'pending review',
+ DATABASE_LOGGING: 'pending review',
+ MAIN_DATABASE_SYNCHRONIZE: 'pending review',
+ };
+
+ const src = readFileSync(join(__dirname, '..', '..', 'config/env.validation.ts'), 'utf8');
+ // `[^\]]` rather than `[\s\S]*?`: env.validation.ts has an earlier `for (const key of [...])`
+ // for the numeric keys, and a lazy any-char match starts at THAT bracket and runs through it to
+ // the checkBool loop's closing one, silently merging both arrays.
+ const block = src.match(/for \(const key of \[([^\]]*?)\]\) \{\s*\n\s*checkBool\(key\);/);
+ expect(block).not.toBeNull();
+ const strictBooleans = [
+ ...new Set([...(block as RegExpMatchArray)[1].matchAll(/'([A-Z][A-Z_0-9]+)'/g)].map(m => m[1])),
+ ];
+ // Guard against a pattern that silently stops matching: an empty list would make this test vacuous.
+ expect(strictBooleans.length).toBeGreaterThan(20);
+
+ const forwarded = apiForwards();
+ const missing = strictBooleans.filter(name => !forwarded.has(name) && !(name in NOT_FORWARDED));
+ expect(missing).toEqual([]);
+
+ // Keep the allowlist honest in the other direction too: an entry that IS forwarded, or that is
+ // no longer a strict boolean, is stale and should be deleted.
+ const staleAllowlist = Object.keys(NOT_FORWARDED).filter(
+ name => forwarded.has(name) || !strictBooleans.includes(name),
+ );
+ expect(staleAllowlist).toEqual([]);
+ });
+
it('forwards the session-ownership keys multi-node deployments set (.env.example "Session ownership")', () => {
const forwarded = apiForwards();
const keys = [