Skip to content

Commit

Permalink
fixed 500 when invalid workflow is presented
Browse files Browse the repository at this point in the history
  • Loading branch information
adpham95 committed Nov 7, 2019
1 parent 996732d commit 24dd7ae
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions api/server/db/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"""
Expand Down

0 comments on commit 24dd7ae

Please sign in to comment.