From 742cc1fb58ddba521ed5de40701b6733fa6115e6 Mon Sep 17 00:00:00 2001 From: AdrianoDev Date: Sun, 26 Apr 2026 12:19:36 +0200 Subject: [PATCH] fix(v2): two regressions surfaced by the local smoke test Both came from the src/ restructure and only show up at runtime, so the test suite had not caught them. - src/backend/config.py: env_file was "../../.env", which pydantic- settings resolves against the *cwd*, not the file. Running uvicorn or alembic from the project root therefore looked for ../../.env one level above the repo and silently fell back to the default DB_PASSWORD ("change_me_in_production"), hiding the real password. Now resolved as Path(__file__).resolve().parents[2] / ".env" so the lookup is always against the project root regardless of cwd. - src/backend/models/orm/__init__.py: Station and StationRecipeAssignment were never imported here, so anything that triggers Base.metadata.create_all without first importing the setup router (which has its own Station import) ended up with no stations / station_recipe_assignments tables. Verified locally: /api/setup/seed used to fail with "Table tiemeasureflow.stations doesn't exist" before this fix. - .gitignore: ignore src/frontend/flask_app/package.json and package-lock.json (local npm-install artifacts; the Dockerfile installs tailwindcss directly). Smoke verified end-to-end: uvicorn + gunicorn + MySQL, login + admin stations + select_recipe + admin users all 200 OK. Co-Authored-By: Claude Opus 4.7 (1M context) --- .gitignore | 3 +++ src/backend/config.py | 9 +++++++-- src/backend/models/orm/__init__.py | 3 +++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 3896acd..7490eaa 100644 --- a/.gitignore +++ b/.gitignore @@ -48,6 +48,8 @@ src/frontend/flask_app/static/css/tailwind.css # Node node_modules/ +src/frontend/flask_app/package.json +src/frontend/flask_app/package-lock.json # Flask-Babel compiled *.mo @@ -70,3 +72,4 @@ nul # Competitor analysis (local only) Concorrente/ +docker-compose.override.yml diff --git a/src/backend/config.py b/src/backend/config.py index ea23376..4281430 100644 --- a/src/backend/config.py +++ b/src/backend/config.py @@ -57,8 +57,13 @@ class Settings(BaseSettings): # Path(__file__) = src/backend/config.py → parents[2] = project root return Path(__file__).resolve().parents[2] / self.upload_dir - # ../../.env reaches the project root from src/backend/. - model_config = {"env_file": "../../.env", "env_file_encoding": "utf-8", "extra": "ignore"} + # Always resolve .env against the project root regardless of cwd + # (pydantic-settings would otherwise treat the path as cwd-relative). + model_config = { + "env_file": str(Path(__file__).resolve().parents[2] / ".env"), + "env_file_encoding": "utf-8", + "extra": "ignore", + } settings = Settings() diff --git a/src/backend/models/orm/__init__.py b/src/backend/models/orm/__init__.py index 90c0a87..5753c76 100644 --- a/src/backend/models/orm/__init__.py +++ b/src/backend/models/orm/__init__.py @@ -5,6 +5,7 @@ from src.backend.models.orm.task import RecipeTask, RecipeSubtask from src.backend.models.orm.measurement import Measurement from src.backend.models.orm.access_log import AccessLog from src.backend.models.orm.setting import SystemSetting, RecipeVersionAudit +from src.backend.models.orm.station import Station, StationRecipeAssignment __all__ = [ "User", @@ -16,4 +17,6 @@ __all__ = [ "AccessLog", "SystemSetting", "RecipeVersionAudit", + "Station", + "StationRecipeAssignment", ]