Restore forgot-password email delivery in Docker deployments#236
Open
Atlas-SZ wants to merge 1 commit intodataelement:mainfrom
Open
Restore forgot-password email delivery in Docker deployments#236Atlas-SZ wants to merge 1 commit intodataelement:mainfrom
Atlas-SZ wants to merge 1 commit intodataelement:mainfrom
Conversation
The Docker Compose backend service was not inheriting the SMTP and reset-password settings from .env, and the email background-task bridge tried to create an asyncio task from a Starlette threadpool worker. Together those two issues produced a success response without a delivered reset email. This change injects the .env file into the backend container and makes async email jobs runnable both with and without an active event loop. It also adds a regression test for the no-running-loop path. Constraint: Docker Compose only interpolates .env by default; it does not inject arbitrary keys into container environments Rejected: Execute reset emails inline in the request path | adds avoidable latency and couples delivery to response timing Rejected: Change forgot-password success masking behavior | out of scope and would alter account-enumeration protections Confidence: high Scope-risk: narrow Directive: Keep async email jobs compatible with both request event loops and Starlette threadpool background tasks Related: dataelement#235 Tested: cd backend && .venv/bin/python -m pytest tests/test_password_reset_and_notifications.py -k 'run_background_email_job_executes_awaitable_without_running_loop or hides_email_delivery_failures or send_system_email_uses_configured_timeout' -q Tested: docker compose config | rg 'SYSTEM_EMAIL_FROM_ADDRESS|PUBLIC_BASE_URL|PASSWORD_RESET_TOKEN_EXPIRE_MINUTES' Not-tested: Full backend test suite Not-tested: Live forgot-password flow against deployed Docker backend
Contributor
Author
|
已实测,合并前辛苦再测一下。 |
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.
Fixes #235
Summary
.envmail/reset settings into the Dockerbackendservice withenv_fileRoot Cause
There were two separate issues affecting forgot-password in Docker deployments:
docker-compose.ymldid not inject the SMTP and reset-password related values from.envinto thebackendcontainer, so the backend could start without the expectedmail configuration.
asyncio.create_task()from a Starlette threadpool worker, which raisedRuntimeError: no running event loopand prevented the mail from being sent even though the API returned a success response.Changes
env_file: ./.envto the Dockerbackendservicerun_background_email_job()to:asyncio.run()when no running event loop existsTest Plan
cd backend && .venv/bin/python -m pytest tests/test_password_reset_and_notifications.py -k 'run_background_email_job_executes_awaitable_without_running_loop or hides_email_delivery_failures or send_system_email_uses_configured_timeout' -qdocker compose config | rg 'SYSTEM_EMAIL_FROM_ADDRESS|PUBLIC_BASE_URL|PASSWORD_RESET_TOKEN_EXPIRE_MINUTES'Notes