From 24dd7aeed5c7b97d8ad610f48ea13f7542657f3c Mon Sep 17 00:00:00 2001 From: adpham95 <32873177+adpham95@users.noreply.github.com> Date: Thu, 7 Nov 2019 11:06:33 -0500 Subject: [PATCH] fixed 500 when invalid workflow is presented --- api/server/db/workflow.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/api/server/db/workflow.py b/api/server/db/workflow.py index b3cf585ba..0c378ea9b 100644 --- a/api/server/db/workflow.py +++ b/api/server/db/workflow.py @@ -2,7 +2,9 @@ from typing import List from uuid import UUID +from fastapi.exceptions import RequestValidationError import jsonschema +import pydantic from pydantic import BaseModel from api.server.db import IDBaseModel @@ -46,8 +48,11 @@ class WorkflowModel(IDBaseModel): start: UUID def __init__(self, **kwargs): - super(WorkflowModel, self).__init__(**kwargs) - self.validate_workflow() + try: + super(WorkflowModel, self).__init__(**kwargs) + self.validate_workflow() + except pydantic.error_wrappers.ValidationError as e: + raise RequestValidationError(e.raw_errors) def validate_workflow(self): """Validates the object"""