diff --git a/services/web/server/src/simcore_service_webserver/application_settings.py b/services/web/server/src/simcore_service_webserver/application_settings.py index c4180ca88f3..46c1c2fd448 100644 --- a/services/web/server/src/simcore_service_webserver/application_settings.py +++ b/services/web/server/src/simcore_service_webserver/application_settings.py @@ -56,7 +56,7 @@ # NOTE: to mark a plugin as a DEV-FEATURE annotated it with # `Field(json_schema_extra={_X_DEV_FEATURE_FLAG: True})` # This will force it to be disabled when WEBSERVER_DEV_FEATURES_ENABLED=False -_X_DEV_FEATURE_FLAG: Final[str] = "x-dev-feature" +_X_FEATURE_UNDER_DEVELOPMENT: Final[str] = "x-dev-feature" class ApplicationSettings(BaseApplicationSettings, MixinLoggingSettings): @@ -108,10 +108,9 @@ class ApplicationSettings(BaseApplicationSettings, MixinLoggingSettings): WEBSERVER_FUNCTIONS: Annotated[ bool, Field( - validation_alias=AliasChoices("WEBSERVER_FUNCTIONS"), - json_schema_extra={_X_DEV_FEATURE_FLAG: True}, + json_schema_extra={_X_FEATURE_UNDER_DEVELOPMENT: True}, ), - ] = False + ] = True WEBSERVER_LOGLEVEL: Annotated[ LogLevel, @@ -406,8 +405,8 @@ def _build_vcs_release_url_if_unset(cls, values): @model_validator(mode="before") @classmethod - def _enable_only_if_dev_features_allowed(cls, data: Any) -> Any: - """Force disables plugins marked 'under development' when WEBSERVER_DEV_FEATURES_ENABLED=False""" + def _disable_features_under_development_in_production(cls, data: Any) -> Any: + """Force disables plugins marked '_X_FEATURE_UNDER_DEVELOPMENT' when WEBSERVER_DEV_FEATURES_ENABLED=False""" dev_features_allowed = TypeAdapter(bool).validate_python( data.get("WEBSERVER_DEV_FEATURES_ENABLED", False) @@ -423,7 +422,8 @@ def _enable_only_if_dev_features_allowed(cls, data: Any) -> Any: field.json_schema_extra(json_schema) assert isinstance(json_schema, dict) # nosec - if json_schema.get(_X_DEV_FEATURE_FLAG): + if json_schema.get(_X_FEATURE_UNDER_DEVELOPMENT): + assert not dev_features_allowed # nosec _logger.warning( "'%s' is still under development and will be forcibly disabled [WEBSERVER_DEV_FEATURES_ENABLED=%s].", field_name, diff --git a/services/web/server/tests/unit/isolated/test_application_settings.py b/services/web/server/tests/unit/isolated/test_application_settings.py index 22c8a210201..bbb021da3d3 100644 --- a/services/web/server/tests/unit/isolated/test_application_settings.py +++ b/services/web/server/tests/unit/isolated/test_application_settings.py @@ -12,7 +12,7 @@ from pytest_simcore.helpers.monkeypatch_envs import setenvs_from_dict from pytest_simcore.helpers.typing_env import EnvVarsDict from simcore_service_webserver.application_settings import ( - _X_DEV_FEATURE_FLAG, + _X_FEATURE_UNDER_DEVELOPMENT, APP_SETTINGS_KEY, ApplicationSettings, setup_settings, @@ -130,17 +130,25 @@ def test_disabled_plugins_settings_to_client_statics( ) class DevSettings(ApplicationSettings): - TEST_FOO: Annotated[bool, Field(json_schema_extra={_X_DEV_FEATURE_FLAG: True})] + TEST_FOO: Annotated[ + bool, Field(json_schema_extra={_X_FEATURE_UNDER_DEVELOPMENT: True}) + ] TEST_BAR: Annotated[ - int | None, Field(json_schema_extra={_X_DEV_FEATURE_FLAG: True}) + int | None, Field(json_schema_extra={_X_FEATURE_UNDER_DEVELOPMENT: True}) ] settings = DevSettings.create_from_envs() if is_dev_feature_enabled: + assert settings.WEBSERVER_DEV_FEATURES_ENABLED is True + assert settings.WEBSERVER_FUNCTIONS is True + assert settings.TEST_FOO is True assert settings.TEST_BAR == 42 else: + assert settings.WEBSERVER_DEV_FEATURES_ENABLED is False + assert settings.WEBSERVER_FUNCTIONS is False + assert settings.TEST_FOO is False assert settings.TEST_BAR is None