fix(users,host): align .env loading + dev-quick-login resolution (#158, #159) - #160
Merged
Conversation
#159) - host/main.py + scaffold template: merge .env into os.environ before importing Settings, so framework code reading os.environ directly sees the same values pydantic-settings does. Scaffold template also chdirs to the workspace root so cwd-relative paths in .env resolve under `cd host && uvicorn main:app`. - users.bootstrap: extract resolve_bootstrap_credentials(settings) — the three-tier (settings → os.environ → .env) resolver shared between the boot-time admin seeder and the login-page dev_accounts builder. - auth_local.views.login_page: use the shared resolver so the "Dev quick-login" buttons appear iff an admin would actually be seeded (previously checked only settings + os.environ, missing the .env path). - Tests: unit coverage for the resolver's three tiers + a login-page regression that exercises the .env fallback end-to-end. Scaffold regression test asserts the dotenv load precedes the Settings import.
Deploying simple-module-python with
|
| Latest commit: |
7037826
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://5365b043.simple-module-python.pages.dev |
| Branch Preview URL: | https://platform-issues.simple-module-python.pages.dev |
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.
Summary
Closes #158 and #159 — two interlocking bugs around
.envresolution in the dev/admin bootstrap path.main.pydoesn't load.envintoos.environ— breaks framework code reading env vars directly #158 (host/main.py+ scaffold template) Now merge.envintoos.environbefore importingSettings, so framework code reading env vars directly (not via pydantic-settings) sees the same values pydantic does. The scaffold template additionallychdirs to the workspace root so cwd-relative paths in.envresolve undercd host && uvicorn main:app.users.endpoints.views.login_pagedev_accountsresolution skips.envfallback — inconsistent withusers.bootstrap#159 (users.auth_local.views.login_page) Extractedresolve_bootstrap_credentials(settings)intousers.bootstrap— the shared three-tier resolver (settings →os.environ→.env). Both the boot-time admin seeder and the "Dev quick-login" buttons now go through it, so the buttons appear iff a seed admin would actually be created.Verification
/users/login(port 8000) with bootstrap creds present only in.env(not in shell env):dev_accounts: [{Admin…}, {User…}]./dashboard/./favicon.ico404 — unrelated).main.pycallsload_dotenv_into_environbefore thesimple_module_hostingimport.make lint,make test-py(1186 passed, 1 skipped),make test-js(16 passed),make build.Test plan
/users/loginwith only.env(no shell env) carryingSM_USERS_BOOTSTRAP_*and confirms Admin/User quick-login buttons render.