Skip to content

Commit c53cab9

Browse files
committed
@GitHK review: validate on server side
1 parent 0510b0b commit c53cab9

File tree

1 file changed

+29
-6
lines changed
  • services/catalog/src/simcore_service_catalog/api/rpc

1 file changed

+29
-6
lines changed

services/catalog/src/simcore_service_catalog/api/rpc/_services.py

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from models_library.rpc_pagination import DEFAULT_NUMBER_OF_ITEMS_PER_PAGE, PageLimitInt
1414
from models_library.services_types import ServiceKey, ServiceVersion
1515
from models_library.users import UserID
16-
from pydantic import NonNegativeInt
16+
from pydantic import NonNegativeInt, ValidationError, validate_call
1717
from pyinstrument import Profiler
1818
from servicelib.logging_utils import log_decorator
1919
from servicelib.rabbitmq import RPCRouter
@@ -53,8 +53,9 @@ async def _wrapper(app: FastAPI, **kwargs):
5353
return _wrapper
5454

5555

56-
@router.expose(reraise_if_error_type=(CatalogForbiddenError,))
56+
@router.expose(reraise_if_error_type=(CatalogForbiddenError, ValidationError))
5757
@_profile_rpc_call
58+
@validate_call(config={"arbitrary_types_allowed": True})
5859
async def list_services_paginated(
5960
app: FastAPI,
6061
*,
@@ -88,9 +89,16 @@ async def list_services_paginated(
8889
)
8990

9091

91-
@router.expose(reraise_if_error_type=(CatalogItemNotFoundError, CatalogForbiddenError))
92+
@router.expose(
93+
reraise_if_error_type=(
94+
CatalogItemNotFoundError,
95+
CatalogForbiddenError,
96+
ValidationError,
97+
)
98+
)
9299
@log_decorator(_logger, level=logging.DEBUG)
93100
@_profile_rpc_call
101+
@validate_call(config={"arbitrary_types_allowed": True})
94102
async def get_service(
95103
app: FastAPI,
96104
*,
@@ -116,8 +124,15 @@ async def get_service(
116124
return service
117125

118126

119-
@router.expose(reraise_if_error_type=(CatalogItemNotFoundError, CatalogForbiddenError))
127+
@router.expose(
128+
reraise_if_error_type=(
129+
CatalogItemNotFoundError,
130+
CatalogForbiddenError,
131+
ValidationError,
132+
)
133+
)
120134
@log_decorator(_logger, level=logging.DEBUG)
135+
@validate_call(config={"arbitrary_types_allowed": True})
121136
async def update_service(
122137
app: FastAPI,
123138
*,
@@ -147,8 +162,15 @@ async def update_service(
147162
return service
148163

149164

150-
@router.expose(reraise_if_error_type=(CatalogItemNotFoundError, CatalogForbiddenError))
165+
@router.expose(
166+
reraise_if_error_type=(
167+
CatalogItemNotFoundError,
168+
CatalogForbiddenError,
169+
ValidationError,
170+
)
171+
)
151172
@log_decorator(_logger, level=logging.DEBUG)
173+
@validate_call(config={"arbitrary_types_allowed": True})
152174
async def check_for_service(
153175
app: FastAPI,
154176
*,
@@ -169,8 +191,9 @@ async def check_for_service(
169191
)
170192

171193

172-
@router.expose(reraise_if_error_type=(CatalogForbiddenError,))
194+
@router.expose(reraise_if_error_type=(CatalogForbiddenError, ValidationError))
173195
@log_decorator(_logger, level=logging.DEBUG)
196+
@validate_call(config={"arbitrary_types_allowed": True})
174197
async def batch_get_my_services(
175198
app: FastAPI,
176199
*,

0 commit comments

Comments
 (0)