OpenWA icon indicating copy to clipboard operation
OpenWA copied to clipboard

[Bug]: Pinned by an environment variable — this is the running value; dashboard changes won't apply until that variable is unset

Open onepay-ye opened this issue 3 months ago • 7 comments

Pre-flight

  • [x] I searched existing issues and this isn't a duplicate
  • [x] I'm on the latest released version (or noted my version below)

OpenWA version

0.14.1

Deployment

Docker Compose

Database

SQLite (default)

WhatsApp engine

whatsapp-web.js

What happened?

An additional problem arises when attempting to change the engine type, save, and restart; no settings are saved at all.

Even though the default value in all environment files is false for Redis, the following message appears:

Pinned by an environment variable — this is the running value; dashboard changes won't apply until that variable is unset.

After investigating the problem, something happened here in this file that caused the engine to fail to save correctly: /var/lib/docker/volumes/openwa_openwa-data/_data/plugins/registry.json

{
    "id": "whatsapp-web.js",
    "type": "engine",
    "name": "WhatsApp Web.js Engine",
    "version": "1.0.0",
    "status": "enabled",
    "config": {},
    "builtIn": true,
    "installedAt": "2026-07-03T18:15:40.011Z",
    "updatedAt": "2026-08-05T22:22:48.527Z",
    "enabledByOperator": true
  },
  {
    "id": "baileys",
    "type": "engine",
    "name": "Baileys Engine",
    "version": "1.0.0",
    "status": "installed",
    "config": {},
    "builtIn": true,
    "installedAt": "2026-07-03T18:15:40.011Z",
    "updatedAt": "2026-08-05T22:22:48.499Z",
    "enabledByOperator": false
  }
Image

Steps to reproduce

.

Expected behavior

No response

Relevant logs


Environment / additional context

No response

onepay-ye avatar Aug 05 '26 22:08 onepay-ye

Thanks for the report — and for going into the data volume and pasting registry.json. That narrowed this down much faster.

Two corrections first, because they change where to look.

plugins/registry.json is a record, not a cause. Every boot re-registers both built-in engines and enables the configured one, so whatsapp-web.js: enabled / baileys: installed just records that the engine resolved to whatsapp-web.js at your last boot. It is never read back when choosing an engine.

Your settings are saved. They are not applied. Reproduced end-to-end on v0.14.1:

Environment data/.env.generated after save After restart
Nothing set ENGINE_TYPE=baileys applies
Bundled compose, nothing set (ENGINE_TYPE=) ENGINE_TYPE=baileys applies
A real value present ENGINE_TYPE=baileys never applies

The API returns success and writes the file in all three. Precedence is container env > .env > data/.env.generated, so any real (non-empty) value wins permanently. The bundled compose forwards these keys empty and empty is treated as unset — so the shipped compose is not what pins you.

The Redis notice is almost certainly correct. The toggle is seeded from the running value, not the saved file. Toggle ON + notice shown means running true, saved false. I reproduced your exact screenshot — toggle ON, "Disconnected", host redis, port 6379, built-in OFF — by booting with a real REDIS_ENABLED=true while data/.env.generated held false. Something in your deployment sets it at runtime despite every file saying false, and that same source is the likely reason the engine change does not stick.

Please paste:

docker compose config | grep -E 'ENGINE_TYPE|REDIS_ENABLED'
docker compose exec openwa-api env | grep -E 'ENGINE_TYPE|REDIS_ENABLED'
docker compose exec openwa-api cat /app/data/.env.generated | grep -E 'ENGINE_TYPE|REDIS_ENABLED'
docker compose logs openwa-api | grep '\[Bootstrap\] Loading'

The last line is printed only when a .env file is found, so it tells us whether the source is a file or the container environment.

Likely sources: a .env beside your docker-compose.yml (Compose interpolates it in), an env_file: entry, variables set in a Coolify/Portainer/Dokploy UI, or a docker-compose.yml older than v0.7.7 — up to v0.7.6 it shipped REDIS_ENABLED=${REDIS_ENABLED:-false}, and v0.7.0 shipped ENGINE_TYPE=${ENGINE_TYPE:-whatsapp-web.js}, as real defaults. docker compose pull never updates that file.

Defects on our side that this exposed, which will be fixed regardless:

  • The Engine card has no environment-pin indicator, so a pinned engine reverts silently. The other three cards have one.
  • The notice is inferred from running-vs-saved mismatch, not from the environment, so it also fires right after a save that has not been restarted yet — where no variable is involved and the wording is simply wrong.
  • The notice never names the responsible variable.

rmyndharis avatar Aug 06 '26 02:08 rmyndharis

Thank u @rmyndharis for reply this is information :

root@server:~/OpenWA# docker compose config | grep -E 'ENGINE_TYPE|REDIS_ENABLED'
docker compose exec openwa-api env | grep -E 'ENGINE_TYPE|REDIS_ENABLED'
docker compose exec openwa-api cat /app/data/.env.generated | grep -E 'ENGINE_TYPE|REDIS_ENABLED'
docker compose logs openwa-api | grep '\[Bootstrap\] Loading'
      ENGINE_TYPE: whatsapp-web.js
      REDIS_ENABLED: ""
REDIS_ENABLED=
ENGINE_TYPE=whatsapp-web.js
ENGINE_TYPE=whatsapp-web.js
REDIS_ENABLED=false
openwa-api  | [Bootstrap] Loading saved configuration from: /app/data/.env.generated

onepay-ye avatar Aug 06 '26 17:08 onepay-ye

Thank you — that output settles it, and it corrects me on one of the two points.

I was wrong about the Redis notice

I said the notice was almost certainly correct and that something in your deployment was setting REDIS_ENABLED=true at runtime. Your output shows the opposite: the variable is empty in the container, false in data/.env.generated, and empty in docker compose config. Nothing is pinning it.

The notice was ours to fix. On 0.14.1 it was not derived from the environment at all — it was inferred from "the running value differs from the saved value", and that is also exactly what a save looks like before the server has been restarted. So a stack with no variable set anywhere could still be told a variable was pinning the setting, and it never said which one.

That is fixed in 0.14.2. The gateway now reports which variables are actually supplied by a layer above data/.env.generated, the page names the variable when one is pinned, and it says a restart is pending when one is not. The two conditions need opposite advice, and they finally get it.

The engine is genuinely pinned, and the pin is on your host

This part holds up. Your container environment carries a real ENGINE_TYPE=whatsapp-web.js, and precedence is container environment → .env → data/.env.generated, so nothing saved from the dashboard can win against it.

Where it comes from is worth being precise about, because it is not our compose file. I checked every released version:

Versions ENGINE_TYPE REDIS_ENABLED
0.1.0 – 0.7.0 ${ENGINE_TYPE:-whatsapp-web.js} ${REDIS_ENABLED:-false}
0.7.2 – 0.7.6 ${ENGINE_TYPE:-} ${REDIS_ENABLED:-false}
0.7.7 – current ${ENGINE_TYPE:-} ${REDIS_ENABLED:-}

Your docker compose config shows ENGINE_TYPE: whatsapp-web.js together with REDIS_ENABLED: "". No version produces that pair: the built-in whatsapp-web.js default only existed up to 0.7.0, and the empty REDIS_ENABLED only starts at 0.7.7. The ranges do not overlap.

So the value is reaching Compose from outside the compose file. Two candidates, because env_file: entries are not used for interpolation:

  • a .env sitting next to your docker-compose.yml, which Compose reads automatically
  • ENGINE_TYPE exported in the shell you run docker compose from

Worth knowing: .env.minimal does ship ENGINE_TYPE=whatsapp-web.js uncommented, so a .env derived from it would do exactly this. .env.example has it commented out.

To confirm:

ls -la ~/OpenWA/.env && grep -n ENGINE_TYPE ~/OpenWA/.env
env | grep ENGINE_TYPE

The [Bootstrap] Loading line in your output does not rule a file out, incidentally — it only reports a .env found inside the container. A .env beside your compose file is consumed by Compose itself, so it never appears there.

Why the engine also looked like it saved nothing

There is a second defect here, and it is ours.

The engine radio seeded from the running engine, which while pinned is the pinned value. Once seeded, saving any field on that page — Redis, storage, a database detail — wrote that value back into data/.env.generated. So a pinned deployment could overwrite the engine you had chosen with the one being forced, which is consistent with your file now holding whatsapp-web.js rather than the engine you selected.

A fix is open in #1116: while a setting is pinned, the radio reflects your saved choice instead, so unsetting the variable actually restores it. The badge and the notice continue to show what is really running.

Suggested order

  1. Upgrade to 0.14.2 or later — the Engine card now warns when ENGINE_TYPE is pinned, which 0.14.1 never did.
  2. Remove ENGINE_TYPE from whichever of the two sources above holds it, then docker compose up -d (a plain docker restart keeps the environment the container was created with).
  3. Select your engine again and save. If the value was overwritten while pinned, it will need choosing once more.

Sorry for sending you after the Redis variable — your output is what showed that was the wrong trail.

rmyndharis avatar Aug 07 '26 02:08 rmyndharis

Correction to the upgrade advice above: use v0.14.3, not 0.14.2.

Both fixes this thread produced are in it — the pin notice that names the responsible variable and covers the Engine card, and the one I described as open at the time: while a setting is pinned, the dashboard no longer writes the pinned value back over the engine you had saved. On 0.14.2 that second problem was still present, so a save could still overwrite your choice.

The rest of the guidance is unchanged: ENGINE_TYPE is reaching your container from a .env beside your docker-compose.yml or from the shell environment, and it has to be removed there before the dashboard can change the engine. After removing it, recreate the container with docker compose up -d rather than docker restart, then pick your engine again — if it was overwritten while pinned, the saved value will need setting once more.

rmyndharis avatar Aug 07 '26 02:08 rmyndharis

Thank you @rmyndharis for your reply. I will update to the latest version and then track any errors and share the event log.

onepay-ye avatar Aug 07 '26 12:08 onepay-ye

One more correction on my side, and then the single check that will close this.

The "not applied yet" notice was broken in the versions I pointed you at

I told you the pin notice was fully repaired in v0.14.3. Half of it was not.

The notice has two jobs: say which variable is pinning a setting when one is, and say a restart is pending when nothing is pinned and you have simply saved without restarting. The first job worked from v0.14.2. The second never fired more than once — the flag that gates it is set when a save succeeds and is never cleared, so from your first successful save onward that half of the notice was dead. It only started working in v0.14.4.

You are on v0.14.4 now, so both halves are live for you. But if you saved anything on 0.14.2 or 0.14.3 and the page stayed silent, that silence meant nothing — it was this bug, not a statement about your environment.

That is the second thing in this thread I got wrong (the Redis notice was the first). Both were ours, and both are fixed.

The one check that settles the engine pin

Your container was carrying a real ENGINE_TYPE=whatsapp-web.js from a .env beside your docker-compose.yml or from your shell. To confirm it is gone, the reliable check is the API, not the shell:

curl -s -H "X-API-Key: <your admin key>" http://localhost:2785/api/infra/status | grep -o '"envPinned":\[[^]]*\]'

"envPinned":[] means nothing is pinned and the dashboard can now change the engine. If ENGINE_TYPE still appears in that list, the variable is still reaching the container and has to be removed at the source, then docker compose up -d to recreate (a plain docker restart keeps the old environment).

The key has to be an admin key that is not scoped to a single session.

Why I am not asking for docker compose config again

Because neither it nor printenv can actually answer this, and I should have said so earlier:

  • A blank ENGINE_TYPE= is deleted before the gateway takes its snapshot, so printenv showing an empty value does not distinguish "unset" from "set to blank".
  • A .env file inside the container pins just as effectively and never appears in a host-side docker compose config.

The envPinned field is derived from what the gateway actually saw at boot, which is the only thing that matters here.

Closing

If envPinned comes back empty and your engine selection now sticks after a restart, this one is done and I will close it. If it still lists ENGINE_TYPE, paste the output and we will find where it is coming from.

rmyndharis avatar Aug 07 '26 16:08 rmyndharis

@rmyndharis Exactly, brother. This has been fixed in recent versions. I will close this bug

onepay-ye avatar Aug 07 '26 16:08 onepay-ye