From bd56a73b63c94bd090d35b4eee0ddd127ff398ad Mon Sep 17 00:00:00 2001 From: v6ole Date: Tue, 4 Aug 2026 16:14:25 +0800 Subject: [PATCH] fix: ignore compose-only runtime variables --- backend/app/config.py | 2 +- backend/tests/test_settings_validation.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/backend/app/config.py b/backend/app/config.py index 4deafe4..4bba2f9 100644 --- a/backend/app/config.py +++ b/backend/app/config.py @@ -71,7 +71,7 @@ class Settings(BaseSettings): # ---------- CORS ---------- CORS_ORIGINS: str = "http://localhost:5173,http://10.10.10.7:5173,http://10.10.10.7" - model_config = {"env_file": ".env", "env_file_encoding": "utf-8"} + model_config = {"env_file": ".env", "env_file_encoding": "utf-8", "extra": "ignore"} @property def CASDOOR_ENDPOINT(self) -> str: diff --git a/backend/tests/test_settings_validation.py b/backend/tests/test_settings_validation.py index 48386d8..6ca5065 100644 --- a/backend/tests/test_settings_validation.py +++ b/backend/tests/test_settings_validation.py @@ -66,3 +66,13 @@ def test_enabled_wecom_delivery_requires_all_credentials(): with pytest.raises(ValueError, match="WECOM"): validate_runtime_settings(settings) + + +def test_ignores_compose_only_environment_fields(): + settings = Settings( + environment="test", + postgres_password="compose-only", + pingwatch_backend_bind="127.0.0.1:18065", + ) + + assert settings.environment == "test"