Repository navigation
Conversation
…cks when SMTP_* is removed The stock docker-compose.yml passes every SMTP_* variable, empty when .env doesn't set them, and an empty variable counted as set, so Settings > Email (SMTP) was locked with no server. Once locked, removing the variables never unlocked it, and mail kept going to the old server. The environment now manages email only when SMTP_HOST names a server; without one the settings are the admin's, and values an earlier SMTP_HOST wrote are cleared.
Contributor
|
Thanks! This is on dev now (fb85346), with the same rule as LiftTrace. |
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.
The stock
docker-compose.ymlpasses everySMTP_*variable, and when.envdoesn't set them they arrive empty, apart fromSMTP_PORT=587andSMTP_SECURE=false.seedSmtpFromEnvcounts any variable that's present as set, so a fresh install from the compose file writes an empty server intoapp_config, setssmtp_env_locked, and Settings > Email (SMTP) shows a locked form with no server in it. The compose file says SMTP can also be set in the Settings UI, but with the stock file it can't.The lock also never comes off. Once
SMTP_*has locked the form, removing the variables and restarting leaves it locked, and the old server stays inapp_config, so mail keeps going to it.seedAiFromEnvalready clears its lock in that case (from NutriTrace #36); SMTP never got the same.With this change the environment manages email only when
SMTP_HOSTnames a server. Then it writes theSMTP_*values it has and locks the form, as before. Without one (unset, or empty as the stock compose passes it), the form is the admin's. If an earlierSMTP_HOSThad locked it, it unlocks and the values that environment wrote are cleared, so mail stops going to a server nobody configures any more. That goes one step further than the AI fix, which keeps the old values after unlocking; I'm happy to keep them instead if you'd rather match it.Tests
scripts/smtp-env-lock.test.jscovers the stock compose values leaving the form unlocked and a server saved in Settings untouched,SMTP_HOSToverriding saved values and locking, removing the variables or emptyingSMTP_HOSTunlocking and clearing, and repeated starts withoutSMTP_*keeping a server set up in Settings. Ondevwithout the fix, three of its five tests fail.What I ran
npm run i18n:checkandnpm testonnode:24-bookworm, the stepsci.ymlruns: 1167 tests, all passing (the 1162 ondevplus these 5)./api/app-config/env-locksand/api/app-configas an admin: with the stock compose values the form is unlocked; withSMTP_HOST=mail.example.comit's locked with that server; withSMTP_*removed it's unlocked and empty. Ondevall three are locked, and the last still holdsmail.example.com.NutriTrace's
devhas the sameseedSmtpFromEnv; I can open the same change there if that helps.