Skip to content

fix(users,host): align .env loading + dev-quick-login resolution (#158, #159) - #160

Merged
antosubash merged 2 commits into
mainfrom
platform-issues
May 21, 2026
Merged

fix(users,host): align .env loading + dev-quick-login resolution (#158, #159)#160
antosubash merged 2 commits into
mainfrom
platform-issues

Conversation

@antosubash

Copy link
Copy Markdown
Owner

Summary

Closes #158 and #159 — two interlocking bugs around .env resolution in the dev/admin bootstrap path.

Verification

  • Browser-verified on /users/login (port 8000) with bootstrap creds present only in .env (not in shell env):
    • Inertia payload includes dev_accounts: [{Admin…}, {User…}].
    • Clicking the "Admin" button logs in and redirects to /dashboard/.
    • Console clean (one pre-existing /favicon.ico 404 — unrelated).
  • New unit tests cover the three-tier precedence (settings beats env, env beats dotenv, dotenv is last) and an integration test asserts the login-page payload picks up creds via the dotenv fallback.
  • New scaffold test asserts the generated main.py calls load_dotenv_into_environ before the simple_module_hosting import.
  • Local CI green: make lint, make test-py (1186 passed, 1 skipped), make test-js (16 passed), make build.

verification

Test plan

  • Reviewer loads /users/login with only .env (no shell env) carrying SM_USERS_BOOTSTRAP_* and confirms Admin/User quick-login buttons render.
  • CI is green.

#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.
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying simple-module-python with  Cloudflare Pages  Cloudflare Pages

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

View logs

@antosubash
antosubash merged commit c74edff into main May 21, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scaffolded host main.py doesn't load .env into os.environ — breaks framework code reading env vars directly

1 participant