fix(docker): forward AUTO_START_SESSIONS to the container - #985
Merged
Conversation
docker-compose.yml never passed AUTO_START_SESSIONS through to openwa-api — not in any revision of the file — so on a stock Docker Compose deployment the flag was inert. Sessions were reset to disconnected at boot and left there, with no error to work from: from the application's point of view nothing was misconfigured, the variable simply never arrived. The omission was easy to miss because every other signal said the feature worked. .env.example documents the setting, docker-compose.dev.yml forwards it, and the application reads and validates it correctly. Forward it blank-defaulted, matching the neighbouring engine options, so an unset value still resolves to the documented opt-out default and only an explicit "true" starts sessions at boot. It is deliberately not added to BLANK_SHADOWED_ENV_KEYS: that list is for keys the dashboard writes to data/.env.generated, and this one is not dashboard-managed. The feature-flags spec now asserts the forward exists, so the same silent gap cannot reopen.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
docker-compose.ymlnever forwardedAUTO_START_SESSIONSinto theopenwa-apiservice. Not in thecurrent file, and not in any revision of it —
git log -S 'AUTO_START_SESSIONS' -- docker-compose.ymlreturns nothing. There is no
env_file:entry either, and.dockerignoreexcludes.env*from thebuild context, so there was no path by which the value could reach the process.
On a stock Docker Compose deployment the flag was therefore inert.
SessionService.onModuleInit()resets previously authenticated sessions to
disconnectedat boot, and with the flag never arriving,onApplicationBootstrap()returned early and left them there. The operator got no error, because fromthe application's point of view nothing was misconfigured — the variable simply was not present.
What made this hard to notice is that every other signal said the feature worked:
.env.example:25documentsAUTO_START_SESSIONS=falseas a setting operators are meant to change.docker-compose.dev.yml:58does forward it, so it behaves correctly in development.feature-flags.ts) and validates it at boot (env.validation.ts).Only the production compose file, where most deployments actually run, dropped it.
Change
One forward added next to the existing engine options, blank-defaulted to match them:
- AUTO_START_SESSIONS=${AUTO_START_SESSIONS:-}Blank-defaulting matters for correctness here.
AUTO_START_SESSIONSis opt-in and read as an exactstring comparison against
"true", so an unset value rendering blank resolves to the documenteddefault of off. Only an explicit
truestarts sessions at boot, which keeps the behaviour of everyexisting deployment unchanged.
The key is deliberately not added to
BLANK_SHADOWED_ENV_KEYS. That list exists for keys thecompose file blank-forwards and the dashboard writes to
data/.env.generated, where a blank forwardwould shadow a saved dashboard value.
AUTO_START_SESSIONSis not dashboard-managed, so it follows thesame pattern as
WWEBJS_AUTH_TIMEOUT_MSandBODY_SIZE_LIMIT: forwarded blank, not cleared.Verification
Rendered config before and after, with
AUTO_START_SESSIONS=truepresent in.env:The feature-flags spec now asserts the forward is present, so the gap cannot silently reopen. The
assertion was checked against a known-negative as well as the current file — it fails both when the
line is removed and when the variable name is misspelled, so it is not a vacuous match.
Full local gate:
format:check,lint,tsc --noEmit -p tsconfig.json(including specs),build,and the
src/configsuite (13 files, 182 tests) all pass.docker compose config -qparses. Nodashboard files are touched.
Scope
This is a packaging fix and does not change application behaviour.
It came out of triage on #981, where sessions come back as
qr_readyafter an upgrade, but it is nota fix for that issue — a missing flag leaves sessions idle at
disconnectedrather than presenting aQR. It is relevant there only because it means the reporter's flag may never have been effective, which
changes how their report should be read. That investigation continues separately.
Follow-up worth tracking separately
The same audit found that the production compose forwards none of the runtime feature flags:
STORE_EPHEMERAL_MESSAGES,RESOLVE_LID_TO_PHONE,SIMULATE_TYPING,SIMULATE_TYPING_MAX_MS,QUEUE_ENABLED,MCP_ENABLED,SERVE_DASHBOARD,SEARCH_ENABLEDandSEARCH_PROVIDERare allabsent as well, and most are documented in
.env.example.They are left out of this PR on purpose. Several carry precedence considerations this one does not —
QUEUE_ENABLEDin particular is written by the dashboard todata/.env.generated, so forwarding itblank without adding it to
BLANK_SHADOWED_ENV_KEYSwould shadow a saved dashboard value and trade onesilent bug for another. Each deserves that judgement made explicitly rather than swept in here.