Skip to content

Commit 5ac6e4e

Browse files
authored
✨ is3453/fail boot if invalid product setup (ITISFoundation#3455)
1 parent f6a91eb commit 5ac6e4e

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class InvalidConfig(ValueError):
2+
# NOTE: If your service can’t load the config on startup for any reason, it should just crash
3+
# SEE https://www.willett.io/posts/precepts/
4+
pass

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from aiohttp import web
66
from aiopg.sa.engine import Engine
77
from pydantic import ValidationError
8+
from servicelib.exceptions import InvalidConfig
89

910
from ._constants import APP_DB_ENGINE_KEY, APP_PRODUCTS_KEY
1011
from .products_db import Product, iter_products
@@ -46,9 +47,9 @@ async def load_products_on_startup(app: web.Application):
4647
log.warning("There is not front-end registered for this product")
4748

4849
except ValidationError as err:
49-
log.error(
50-
"Invalid product in db '%s'. Skipping product info:\n %s", row, err
51-
)
50+
raise InvalidConfig(
51+
f"Invalid product configuration in db '{row}':\n {err}"
52+
) from err
5253

5354
if FRONTEND_APP_DEFAULT not in app_products.keys():
5455
log.warning("Default front-end app is not in the products table")

0 commit comments

Comments
 (0)