Skip to content

Calnode silently ignores specific env vars #238

Closed

Description

@M4dhav

Before submitting

  • I've searched existing issues and this isn't a duplicate.
  • This is a reproducible bug in Calnode — not a configuration/setup question or a feature request.

What's the bug?

Despite the documentation suggesting otherwise, certain variables are fetched from the DB even if differing env vars exist. Calnode should always pick the env vars as the one with higher precedence.

Steps to reproduce

Deploy Calnode with env vars
Change email related env vars
redeploy
notice that it has not changed in the ui

Calnode version / commit

0.12

How are you running Calnode?

Self-hosted — Docker

Logs, screenshots, or anything else

No response

Activity

  1. pullfrog commented on Nov 7, 2026

    @pullfrog
    Contributor
  2. M4dhav commented on Nov 7, 2026

    @M4dhav
    Author

    I am ready to open the PR for this, please lmk if this is indeed a bug and not intended

  3. shockalotti commented on Nov 7, 2026

    @shockalotti
    Contributor

    Short version: intended precedence, real silent-failure bug. Please don't flip the precedence — but you're right that it shouldn't be silent.

    Email and Google OAuth settings live in the database, and those stored values win over the environment. On first boot the env vars are seeded into the database (seedSMTPToDB only writes WHERE smtp_host = ''), so changing EMAIL_SMTP_* and redeploying afterwards has no effect. That's deliberate: Settings → Email is the live, UI-editable source of truth, and a stale env var overriding a deliberate UI change on the next restart would be worse than the current behaviour.

    What was genuinely wrong is that nothing told you. Opened #239 for that:

    • DEPLOY.md now states the precedence above the env table, and the SMTP/Google rows say they seed the database rather than "can also be set later".
    • Boot logs a warning naming every variable it is ignoring:
    WARN mailer: ignoring environment settings — the database configuration takes
         precedence; change it in Settings → Email, or clear the stored settings
         there to fall back to the environment   ignored=[EMAIL_SMTP_HOST]
    

    Workaround until it lands: clear the SMTP host in Settings → Email (or the Google credentials in Settings → Google) and restart. With the stored value empty, the env vars are read and re-seed it.

    If you'd still like to contribute, a PR improving the docs or the warning is very welcome — but inverting the precedence would break UI-editable settings, so that part we'd have to decline.

  4. M4dhav commented on Nov 9, 2026

    @M4dhav
    Author

    I still think we should flip the precedence, like many other projects do. My implementation was conditional anyways, such that the env is only preferred if all the variables of a group are complete, and otherwise it picks whatever is stored in the db.

  5. shockalotti commented on Nov 9, 2026

    @shockalotti
    Contributor

    Your conditional design is a genuine improvement over a naive flip — "all variables of a group present, otherwise use the DB" removes the half-configured case (env host with no password), which is the dangerous one. I want to acknowledge that properly, because my objection isn't to how you'd implement it.

    It's to what the default would mean. Under env-wins, an operator who sets SMTP in Settings → Email — the thing the UI exists for — gets silently overridden on the next restart by whatever the compose file still says. That's the same silent surprise you reported, just pointing the other way. And "many other projects do it" is fair, but those are usually stateless apps where env is the config; Calnode's settings are mutable at runtime, so the two sources genuinely compete.

    So the decision, for now: DB-wins stays the default, and #239 lands to make the override visible. That closes the bug you actually hit — it's no longer silent — without changing which source is authoritative.

    But I'd take your version as an explicit mode. If you want to build it:

    CALNODE_SETTINGS_SOURCE=env|db     (default: db)
    

    That gives you the 12-factor behaviour you want without making it a surprise for everyone else, and your group-completeness logic is exactly the right implementation for the env mode — I wouldn't rewrite it.

    If that's something you'd like to pick up, say so and I'll open an issue for it with the above as the spec. Otherwise #239 is the fix for the reported symptom.

    One practical note regardless: the workaround today is to clear the SMTP host in Settings → Email and restart, at which point the env vars are read and re-seed the database.

  6. added a commit that references this issue on Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions