Skip to content

Commit e25c5e5

Browse files
GitHKAndrei Neagu
andauthored
🐛 Fixes broken anonymous user opening templates (#6149)
Co-authored-by: Andrei Neagu <[email protected]>
1 parent 7cfca21 commit e25c5e5

File tree

5 files changed

+25
-5
lines changed

5 files changed

+25
-5
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
ClusterAccessForbiddenError,
4040
ClusterNotFoundError,
4141
PipelineNotFoundError,
42+
ProjectNetworkNotFoundError,
4243
ProjectNotFoundError,
4344
)
4445
from .events import on_shutdown, on_startup
@@ -57,6 +58,12 @@ def _set_exception_handlers(app: FastAPI):
5758
status.HTTP_404_NOT_FOUND, ProjectNotFoundError
5859
),
5960
)
61+
app.add_exception_handler(
62+
ProjectNetworkNotFoundError,
63+
make_http_error_handler_for_exception(
64+
status.HTTP_404_NOT_FOUND, ProjectNetworkNotFoundError
65+
),
66+
)
6067
app.add_exception_handler(
6168
PipelineNotFoundError,
6269
make_http_error_handler_for_exception(

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,14 @@ def __init__(self, project_id: ProjectID):
9292
self.project_id = project_id
9393

9494

95+
class ProjectNetworkNotFoundError(DirectorError):
96+
"""Project not found error"""
97+
98+
def __init__(self, project_id: ProjectID):
99+
super().__init__(f"no networks forund for project {project_id}")
100+
self.project_id = project_id
101+
102+
95103
class PricingPlanUnitNotFoundError(DirectorError):
96104
"""Pricing plan unit not found error"""
97105

services/director-v2/src/simcore_service_director_v2/modules/db/repositories/projects_networks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from models_library.projects_networks import NetworksWithAliases, ProjectsNetworks
77
from sqlalchemy.dialects.postgresql import insert as pg_insert
88

9-
from ....core.errors import ProjectNotFoundError
9+
from ....core.errors import ProjectNetworkNotFoundError
1010
from ..tables import projects_networks
1111
from ._base import BaseRepository
1212

@@ -22,7 +22,7 @@ async def get_projects_networks(self, project_id: ProjectID) -> ProjectsNetworks
2222
)
2323
).first()
2424
if not row:
25-
raise ProjectNotFoundError(project_id)
25+
raise ProjectNetworkNotFoundError(project_id)
2626
return ProjectsNetworks.from_orm(row)
2727

2828
async def upsert_projects_networks(

services/director-v2/src/simcore_service_director_v2/modules/projects_networks.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from servicelib.rabbitmq import RabbitMQClient
2222
from servicelib.utils import logged_gather
2323

24-
from ..core.errors import ProjectNotFoundError
24+
from ..core.errors import ProjectNetworkNotFoundError
2525
from ..modules.db.repositories.projects import ProjectsRepository
2626
from ..modules.db.repositories.projects_networks import ProjectsNetworksRepository
2727
from ..modules.director_v0 import DirectorV0Client
@@ -247,9 +247,9 @@ async def update_from_workbench(
247247
project_id=project_id
248248
)
249249
)
250-
except ProjectNotFoundError:
250+
except ProjectNetworkNotFoundError:
251251
existing_projects_networks = ProjectsNetworks.parse_obj(
252-
dict(project_uuid=project_id, networks_with_aliases={})
252+
{"project_uuid": project_id, "networks_with_aliases": {}}
253253
)
254254

255255
existing_networks_with_aliases = existing_projects_networks.networks_with_aliases

services/web/server/src/simcore_service_webserver/studies_dispatcher/_studies_access.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
NOTE: Some of the code below is duplicated in the studies_dispatcher!
1313
SEE refactoring plan in https://github.com/ITISFoundation/osparc-simcore/issues/3977
1414
"""
15+
1516
import functools
1617
import logging
1718
from functools import lru_cache
@@ -26,6 +27,9 @@
2627

2728
from .._constants import INDEX_RESOURCE_NAME
2829
from ..director_v2._core_computations import create_or_update_pipeline
30+
from ..director_v2._core_dynamic_services import (
31+
update_dynamic_service_networks_in_project,
32+
)
2933
from ..products.api import get_current_product, get_product_name
3034
from ..projects.db import ANY_USER, ProjectDBAPI
3135
from ..projects.exceptions import ProjectInvalidRightsError, ProjectNotFoundError
@@ -184,6 +188,7 @@ async def copy_study_to_account(
184188
await create_or_update_pipeline(
185189
request.app, user["id"], project["uuid"], product_name
186190
)
191+
await update_dynamic_service_networks_in_project(request.app, project["uuid"])
187192

188193
return project_uuid
189194

0 commit comments

Comments
 (0)