Skip to content

Commit b422df3

Browse files
authored
🐛 Fixes WEBSERVER_FUNCTIONS to run in development deploys (#7687)
1 parent 17ccd74 commit b422df3

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

services/web/server/src/simcore_service_webserver/application_settings.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
# NOTE: to mark a plugin as a DEV-FEATURE annotated it with
5757
# `Field(json_schema_extra={_X_DEV_FEATURE_FLAG: True})`
5858
# This will force it to be disabled when WEBSERVER_DEV_FEATURES_ENABLED=False
59-
_X_DEV_FEATURE_FLAG: Final[str] = "x-dev-feature"
59+
_X_FEATURE_UNDER_DEVELOPMENT: Final[str] = "x-dev-feature"
6060

6161

6262
class ApplicationSettings(BaseApplicationSettings, MixinLoggingSettings):
@@ -108,10 +108,9 @@ class ApplicationSettings(BaseApplicationSettings, MixinLoggingSettings):
108108
WEBSERVER_FUNCTIONS: Annotated[
109109
bool,
110110
Field(
111-
validation_alias=AliasChoices("WEBSERVER_FUNCTIONS"),
112-
json_schema_extra={_X_DEV_FEATURE_FLAG: True},
111+
json_schema_extra={_X_FEATURE_UNDER_DEVELOPMENT: True},
113112
),
114-
] = False
113+
] = True
115114

116115
WEBSERVER_LOGLEVEL: Annotated[
117116
LogLevel,
@@ -406,8 +405,8 @@ def _build_vcs_release_url_if_unset(cls, values):
406405

407406
@model_validator(mode="before")
408407
@classmethod
409-
def _enable_only_if_dev_features_allowed(cls, data: Any) -> Any:
410-
"""Force disables plugins marked 'under development' when WEBSERVER_DEV_FEATURES_ENABLED=False"""
408+
def _disable_features_under_development_in_production(cls, data: Any) -> Any:
409+
"""Force disables plugins marked '_X_FEATURE_UNDER_DEVELOPMENT' when WEBSERVER_DEV_FEATURES_ENABLED=False"""
411410

412411
dev_features_allowed = TypeAdapter(bool).validate_python(
413412
data.get("WEBSERVER_DEV_FEATURES_ENABLED", False)
@@ -423,7 +422,8 @@ def _enable_only_if_dev_features_allowed(cls, data: Any) -> Any:
423422
field.json_schema_extra(json_schema)
424423

425424
assert isinstance(json_schema, dict) # nosec
426-
if json_schema.get(_X_DEV_FEATURE_FLAG):
425+
if json_schema.get(_X_FEATURE_UNDER_DEVELOPMENT):
426+
assert not dev_features_allowed # nosec
427427
_logger.warning(
428428
"'%s' is still under development and will be forcibly disabled [WEBSERVER_DEV_FEATURES_ENABLED=%s].",
429429
field_name,

services/web/server/tests/unit/isolated/test_application_settings.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from pytest_simcore.helpers.monkeypatch_envs import setenvs_from_dict
1313
from pytest_simcore.helpers.typing_env import EnvVarsDict
1414
from simcore_service_webserver.application_settings import (
15-
_X_DEV_FEATURE_FLAG,
15+
_X_FEATURE_UNDER_DEVELOPMENT,
1616
APP_SETTINGS_KEY,
1717
ApplicationSettings,
1818
setup_settings,
@@ -130,17 +130,25 @@ def test_disabled_plugins_settings_to_client_statics(
130130
)
131131

132132
class DevSettings(ApplicationSettings):
133-
TEST_FOO: Annotated[bool, Field(json_schema_extra={_X_DEV_FEATURE_FLAG: True})]
133+
TEST_FOO: Annotated[
134+
bool, Field(json_schema_extra={_X_FEATURE_UNDER_DEVELOPMENT: True})
135+
]
134136
TEST_BAR: Annotated[
135-
int | None, Field(json_schema_extra={_X_DEV_FEATURE_FLAG: True})
137+
int | None, Field(json_schema_extra={_X_FEATURE_UNDER_DEVELOPMENT: True})
136138
]
137139

138140
settings = DevSettings.create_from_envs()
139141

140142
if is_dev_feature_enabled:
143+
assert settings.WEBSERVER_DEV_FEATURES_ENABLED is True
144+
assert settings.WEBSERVER_FUNCTIONS is True
145+
141146
assert settings.TEST_FOO is True
142147
assert settings.TEST_BAR == 42
143148
else:
149+
assert settings.WEBSERVER_DEV_FEATURES_ENABLED is False
150+
assert settings.WEBSERVER_FUNCTIONS is False
151+
144152
assert settings.TEST_FOO is False
145153
assert settings.TEST_BAR is None
146154

0 commit comments

Comments
 (0)