Skip to content

Commit e7ba88a

Browse files
continue fixing
1 parent 9586ea8 commit e7ba88a

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from typing import Any
1111

1212
from aiohttp import web
13+
from common_library.pydantic_fields_extension import get_type, is_nullable
1314
from pydantic.types import SecretStr
1415
from servicelib.aiohttp.typing_extension import Handler
1516

@@ -200,10 +201,10 @@ def convert_to_environ_vars( # noqa: C901, PLR0915, PLR0912
200201
def _set_if_disabled(field_name, section):
201202
# Assumes that by default is enabled
202203
enabled = section.get("enabled", True)
203-
field = ApplicationSettings.__fields__[field_name]
204+
field = ApplicationSettings.model_fields[field_name]
204205
if not enabled:
205-
envs[field_name] = "null" if field.allow_none else "0"
206-
elif field.type_ == bool:
206+
envs[field_name] = "null" if is_nullable(field) else "0"
207+
elif get_type(field) == bool:
207208
envs[field_name] = "1"
208209

209210
if main := cfg.get("main"):

services/web/server/src/simcore_service_webserver/payments/settings.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
PositiveInt,
1010
SecretStr,
1111
TypeAdapter,
12+
ValidationInfo,
1213
field_validator,
1314
)
1415
from settings_library.base import BaseCustomSettings
@@ -101,8 +102,8 @@ def _payments_cannot_be_faken_in_production(cls, v):
101102

102103
@field_validator("PAYMENTS_AUTORECHARGE_DEFAULT_MONTHLY_LIMIT")
103104
@classmethod
104-
def _monthly_limit_greater_than_top_up(cls, v, values):
105-
top_up = values["PAYMENTS_AUTORECHARGE_DEFAULT_TOP_UP_AMOUNT"]
105+
def _monthly_limit_greater_than_top_up(cls, v, info: ValidationInfo):
106+
top_up = info.data["PAYMENTS_AUTORECHARGE_DEFAULT_TOP_UP_AMOUNT"]
106107
if v < 2 * top_up:
107108
msg = "PAYMENTS_AUTORECHARGE_DEFAULT_MONTHLY_LIMIT (={v}) should be at least twice PAYMENTS_AUTORECHARGE_DEFAULT_TOP_UP_AMOUNT ({top_up})"
108109
raise ValueError(msg)

0 commit comments

Comments
 (0)