Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(compose): forward the send-pacing, media-conversion and session-ownership env keys
Yudhi Armyndharis5c98c048b4d1
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 1f424ebb4..44e7f2070 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0- **Voice notes on the Baileys engine now carry a waveform.**- The webhook producer enqueues idempotently, and the bundled Redis is pinned `--maxmemory-policy noeviction` so queued jobs are not silently dropped.- A media-storage root the app cannot write to is caught at boot with a clear error, instead of failing on the first write (#1066).+- The bundled `docker-compose.yml` now forwards the `SEND_PACING_*`, `MEDIA_CONVERSION_*`/`FFMPEG_PATH` and session-ownership (`NODE_ID`, `NODE_URL`, lease/sweep) variables — previously these features could not be enabled from `.env` in a compose deployment at all.- Corrected column names in `docs/05-database-design.md`.### Security@@ -366,6 +367,7 @@ The session-lifecycle security hardening release: lifecycle and logout operation## [0.10.3] - 2026-07-21> ⚠️ **Two behaviour changes on already-released surfaces.**+>> 1. **Boolean and numeric request fields are read strictly.** `1`/`0`/`yes`/`no` or a blank number now returns `400`; real JSON booleans/numbers, `"true"`/`"false"`, and numeric strings such as `"5"` still work.> 2. **Status posts now pass the `message:sending` plugin gate.** A broadly-blocking plugin will now block status posts, and the gate `input` for a status post carries no `chatId`.diff --git a/docker-compose.yml b/docker-compose.ymlindex c2c876ae3..9d84c3003 100644--- a/docker-compose.yml+++ b/docker-compose.yml@@ -155,6 +155,16 @@ services:# "true", so a blank forward (nothing set) keeps the default off. Without this line the value in# .env never reaches the container and the flag silently does nothing.- AUTO_START_SESSIONS=${AUTO_START_SESSIONS:-}+ # Session ownership / multi-node routing (see the "Session ownership" section of .env.example+ # and docs/13). NODE_ID must be STABLE across restarts: the app default (the container+ # hostname) changes on every recreate, making the new container a "new node" that has to wait+ # out its previous identity's lease before re-adopting sessions.+ - NODE_ID=${NODE_ID:-}+ - NODE_URL=${NODE_URL:-}+ - SESSION_LEASE_TTL_MS=${SESSION_LEASE_TTL_MS:-}+ - SESSION_LEASE_HEARTBEAT_MS=${SESSION_LEASE_HEARTBEAT_MS:-}+ - SESSION_TAKEOVER_SWEEP_MS=${SESSION_TAKEOVER_SWEEP_MS:-}+ - SESSION_PROXY_TIMEOUT_MS=${SESSION_PROXY_TIMEOUT_MS:-}# Storage. Blank-forwarded (see Database note) so a dashboard local↔S3 switch applies; a real# host value pins. Credentials use the canonical S3_ACCESS_KEY_ID / S3_SECRET_ACCESS_KEY names the# app and dashboard write; the legacy S3_ACCESS_KEY / S3_SECRET_KEY are ALSO forwarded (and read@@ -177,6 +187,20 @@ services:- CHAT_MEDIA_ARCHIVE_TTL_DAYS=${CHAT_MEDIA_ARCHIVE_TTL_DAYS:-}- CHAT_MEDIA_ORPHAN_SWEEP_INTERVAL_MS=${CHAT_MEDIA_ORPHAN_SWEEP_INTERVAL_MS:-}- CHAT_MEDIA_ORPHAN_GRACE_MS=${CHAT_MEDIA_ORPHAN_GRACE_MS:-}+ # Send pacing (opt-in anti-ban governor). Forwarded explicitly for the same reason as the+ # chat-media block above: without these lines SEND_PACING_ENABLED=true in the operator's .env+ # never reaches the container and every send stays unpaced with no signal anywhere.+ - SEND_PACING_ENABLED=${SEND_PACING_ENABLED:-}+ - SEND_PACING_WARMUP_SCHEDULE=${SEND_PACING_WARMUP_SCHEDULE:-}+ - SEND_PACING_COLD_DAILY_CAP=${SEND_PACING_COLD_DAILY_CAP:-}+ - SEND_PACING_BREAKER_THRESHOLD=${SEND_PACING_BREAKER_THRESHOLD:-}+ - SEND_PACING_BREAKER_COOLDOWN_MS=${SEND_PACING_BREAKER_COOLDOWN_MS:-}+ # Server-side media conversion (opt-in). The image ships ffmpeg, but without these forwards+ # the feature could not be switched on from .env at all.+ - MEDIA_CONVERSION_ENABLED=${MEDIA_CONVERSION_ENABLED:-}+ - FFMPEG_PATH=${FFMPEG_PATH:-}+ - MEDIA_CONVERSION_TIMEOUT_MS=${MEDIA_CONVERSION_TIMEOUT_MS:-}+ - MEDIA_CONVERSION_MAX_OUTPUT_BYTES=${MEDIA_CONVERSION_MAX_OUTPUT_BYTES:-}# Redis. Blank-forwarded (see Database note) so a dashboard enable/disable applies; a real host# value pins.- REDIS_ENABLED=${REDIS_ENABLED:-}diff --git a/src/config/env-precedence.ts b/src/config/env-precedence.tsindex 12137f85e..baaa534bf 100644--- a/src/config/env-precedence.ts+++ b/src/config/env-precedence.ts@@ -51,6 +51,26 @@ export const BLANK_SHADOWED_ENV_KEYS: string[] = ['CHAT_MEDIA_ARCHIVE_TTL_DAYS','CHAT_MEDIA_ORPHAN_SWEEP_INTERVAL_MS','CHAT_MEDIA_ORPHAN_GRACE_MS',+ // Send pacing. Blank-forwarded by compose like the chat-media keys, so an operator who sets+ // nothing must not have an empty string pin pacing off against .env / data/.env.generated.+ 'SEND_PACING_ENABLED',+ 'SEND_PACING_WARMUP_SCHEDULE',+ 'SEND_PACING_COLD_DAILY_CAP',+ 'SEND_PACING_BREAKER_THRESHOLD',+ 'SEND_PACING_BREAKER_COOLDOWN_MS',+ // Server-side media conversion, same arrangement.+ 'MEDIA_CONVERSION_ENABLED',+ 'FFMPEG_PATH',+ 'MEDIA_CONVERSION_TIMEOUT_MS',+ 'MEDIA_CONVERSION_MAX_OUTPUT_BYTES',+ // Session ownership / multi-node routing (docs/13). Blank-forwarded so the single-node default+ // stays untouched while .env / data/.env.generated can supply real values.+ 'NODE_ID',+ 'NODE_URL',+ 'SESSION_LEASE_TTL_MS',+ 'SESSION_LEASE_HEARTBEAT_MS',+ 'SESSION_TAKEOVER_SWEEP_MS',+ 'SESSION_PROXY_TIMEOUT_MS',// 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.tsindex 8a504de3f..00b811841 100644--- a/src/modules/docker/compose-parity.spec.ts+++ b/src/modules/docker/compose-parity.spec.ts@@ -235,21 +235,42 @@ describe('DockerService managed specs ↔ docker-compose.yml parity', () => {expect(cfg.Env).toBeUndefined();});- it('forwards every CHAT_MEDIA_* variable the app reads to the api container', () => {- // docker-compose.yml has NO env_file — the `environment:` list is an explicit allow-list, so a- // variable missing from it never reaches the container and the feature it gates stays silently- // off however the operator's .env is written. Exactly how AUTO_START_SESSIONS was inert before- // v0.12.0. Derived from configuration.ts rather than hardcoded, so a new flag cannot be added- // to the app and forgotten here.- const configSrc = readFileSync(join(__dirname, '..', '..', 'config', 'configuration.ts'), 'utf8');- const read = [...new Set(configSrc.match(/CHAT_MEDIA_[A-Z_]+/g) ?? [])];- expect(read.length).toBeGreaterThan(0);-+ // docker-compose.yml has NO env_file — the `environment:` list is an explicit allow-list, so a+ // variable missing from it never reaches the container and the feature it gates stays silently+ // off however the operator's .env is written. Exactly how AUTO_START_SESSIONS was inert before+ // v0.12.0, and how SEND_PACING_* / MEDIA_CONVERSION_* shipped inert alongside CHAT_MEDIA_*.+ const apiForwards = (): Set<string> => {const api = (compose.services as Record<string, { environment?: string[] }>)['openwa-api'];- const forwarded = new Set((api.environment ?? []).map(line => line.split('=')[0]));+ return new Set((api.environment ?? []).map(line => line.split('=')[0]));+ };++ it.each([+ ['CHAT_MEDIA_*', 'config/configuration.ts', /CHAT_MEDIA_[A-Z_]+/g],+ ['MEDIA_CONVERSION_*/FFMPEG_PATH', 'config/configuration.ts', /MEDIA_CONVERSION_[A-Z_]+|FFMPEG_PATH/g],+ ['SEND_PACING_*', 'modules/message/send-pacing.config.ts', /SEND_PACING_[A-Z_]+/g],+ ])('forwards every %s variable the app reads to the api container', (_family, sourcePath, pattern) => {+ // Derived from the reading source file rather than hardcoded, so a new flag cannot be added to+ // the app and forgotten here.+ const src = readFileSync(join(__dirname, '..', '..', sourcePath), 'utf8');+ const read = [...new Set(src.match(pattern) ?? [])];+ expect(read.length).toBeGreaterThan(0);+ const forwarded = apiForwards();expect(read.filter(name => !forwarded.has(name))).toEqual([]);});+ it('forwards the session-ownership keys multi-node deployments set (.env.example "Session ownership")', () => {+ const forwarded = apiForwards();+ const keys = [+ 'NODE_ID',+ 'NODE_URL',+ 'SESSION_LEASE_TTL_MS',+ 'SESSION_LEASE_HEARTBEAT_MS',+ 'SESSION_TAKEOVER_SWEEP_MS',+ 'SESSION_PROXY_TIMEOUT_MS',+ ];+ expect(keys.filter(name => !forwarded.has(name))).toEqual([]);+ });+it('redis: sets the noeviction maxmemory policy BullMQ requires, on both launch paths', async () => {const cfg = await capture('redis');// The parity assertion above only proves the two launch paths AGREE — dropping the flag from