Skip to content

Commit 821aa5c

Browse files
authored
🐛 OSPARC_API_BASE_URL variable ends with / (#7042)
1 parent 99746e4 commit 821aa5c

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

services/director-v2/src/simcore_service_director_v2/core/settings.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
NoAuthentication,
1717
)
1818
from pydantic import (
19+
AfterValidator,
1920
AliasChoices,
2021
AnyHttpUrl,
2122
AnyUrl,
@@ -251,10 +252,14 @@ class AppSettings(BaseApplicationSettings, MixinLoggingSettings):
251252
description="resource usage tracker service client's plugin",
252253
)
253254

254-
DIRECTOR_V2_PUBLIC_API_BASE_URL: AnyHttpUrl = Field(
255-
...,
256-
description="Base URL used to access the public api e.g. http://127.0.0.1:6000 for development or https://api.osparc.io",
257-
)
255+
DIRECTOR_V2_PUBLIC_API_BASE_URL: Annotated[
256+
AnyHttpUrl | str,
257+
AfterValidator(lambda v: f"{v}".rstrip("/")),
258+
Field(
259+
...,
260+
description="Base URL used to access the public api e.g. http://127.0.0.1:6000 for development or https://api.osparc.io",
261+
),
262+
]
258263
DIRECTOR_V2_TRACING: TracingSettings | None = Field(
259264
json_schema_extra={"auto_default_from_env": True},
260265
description="settings for opentelemetry tracing",

services/director-v2/src/simcore_service_director_v2/modules/osparc_variables/substitutions.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
""" Substitution of osparc variables and secrets
2-
3-
"""
1+
"""Substitution of osparc variables and secrets"""
42

53
import functools
64
import logging
@@ -24,6 +22,7 @@
2422
from pydantic import BaseModel
2523
from servicelib.fastapi.app_state import SingletonInAppStateMixin
2624
from servicelib.logging_utils import log_context
25+
from simcore_service_director_v2.core.settings import get_application_settings
2726

2827
from ...utils.db import get_repository
2928
from ...utils.osparc_variables import (
@@ -194,6 +193,7 @@ async def resolve_and_substitute_session_variables_in_model(
194193
# if it raises an error vars need replacement
195194
raise_if_unresolved_osparc_variable_identifier_found(model)
196195
except UnresolvedOsparcVariableIdentifierError:
196+
app_settings = get_application_settings(app)
197197
table = OsparcSessionVariablesTable.get_from_app_state(app)
198198
identifiers = await resolve_variables_from_context(
199199
table.copy(),
@@ -204,7 +204,7 @@ async def resolve_and_substitute_session_variables_in_model(
204204
project_id=project_id,
205205
node_id=node_id,
206206
run_id=service_run_id,
207-
api_server_base_url=app.state.settings.DIRECTOR_V2_PUBLIC_API_BASE_URL,
207+
api_server_base_url=app_settings.DIRECTOR_V2_PUBLIC_API_BASE_URL,
208208
),
209209
)
210210
_logger.debug("replacing with the identifiers=%s", identifiers)
@@ -238,6 +238,7 @@ async def resolve_and_substitute_session_variables_in_specs(
238238
identifiers_to_replace,
239239
)
240240
if identifiers_to_replace:
241+
app_settings = get_application_settings(app)
241242
environs = await resolve_variables_from_context(
242243
table.copy(include=identifiers_to_replace),
243244
context=ContextDict(
@@ -247,7 +248,7 @@ async def resolve_and_substitute_session_variables_in_specs(
247248
project_id=project_id,
248249
node_id=node_id,
249250
run_id=service_run_id,
250-
api_server_base_url=app.state.settings.DIRECTOR_V2_PUBLIC_API_BASE_URL,
251+
api_server_base_url=app_settings.DIRECTOR_V2_PUBLIC_API_BASE_URL,
251252
),
252253
)
253254

0 commit comments

Comments
 (0)