@@ -87,10 +87,11 @@ def __immutable_multi_dict_to_nested_dict(
8787def __validate_run_workflow_request (data : Dict ) -> None :
8888 """Validates presence and types of workflow run request form data; sets
8989 defaults for optional fields."""
90+
9091 # The form data is not validated properly because all types except
9192 # 'workflow_attachment' are string and none are labeled as required
92- # Considering the 'RunRequest' model in the current specs (0.3.0) , the
93- # following assumptions are made and verified for the indicated parameters:
93+ # Considering the 'RunRequest' model in the specs, the following
94+ # assumptions are made and verified for the indicated parameters:
9495 # workflow_params:
9596 # type = dict
9697 # required = True
@@ -113,8 +114,7 @@ def __validate_run_workflow_request(data: Dict) -> None:
113114 # type = [str]
114115 # required = False
115116
116- # Set required parameters
117- required = {
117+ params_required = {
118118 'workflow_params' ,
119119 'workflow_type' ,
120120 'workflow_type_version' ,
@@ -130,22 +130,29 @@ def __validate_run_workflow_request(data: Dict) -> None:
130130 'workflow_engine_parameters' ,
131131 'tags' ,
132132 ]
133- type_str = dict ((key , data [key ]) for key in params_str if key in data )
134- type_dict = dict ((key , data [key ]) for key in params_dict if key in data )
135- # TODO: implement type casting/checking for workflow attachment
136133
137134 # Raise error if any required params are missing
138- if not required <= set (data ):
139- logger .error ('POST request does not conform to schema.' )
140- raise BadRequest
135+ invalid = False
136+ for param in params_required :
137+ if param not in data :
138+ logger .error (f"Required parameter '{ param } ' not in request body." )
139+ invalid = True
141140
142141 # Raise error if any string params are not of type string
143- if not all (isinstance (value , str ) for value in type_str .values ()):
144- logger .error ('POST request does not conform to schema.' )
145- raise BadRequest
142+ for param in params_str :
143+ if param in data and not isinstance (data [param ], str ):
144+ logger .error (f"Parameter '{ param } ' is not of string type." )
145+ invalid = True
146146
147147 # Raise error if any dict params are not of type dict
148- if not all (isinstance (value , dict ) for value in type_dict .values ()):
148+ for param in params_dict :
149+ if param in data and not isinstance (data [param ], dict ):
150+ logger .error (
151+ f"Parameter '{ param } ' is not of dictionary type. Invalid JSON?"
152+ )
153+ invalid = True
154+
155+ if invalid :
149156 logger .error ('POST request does not conform to schema.' )
150157 raise BadRequest
151158
@@ -154,7 +161,7 @@ def __validate_run_workflow_request(data: Dict) -> None:
154161
155162def __check_service_info_compatibility (data : Dict ) -> None :
156163 """Checks compatibility with service info; raises BadRequest."""
157- # TODO: implement me
164+ # TODO: implement
158165 return None
159166
160167
@@ -285,6 +292,8 @@ def __create_run_environment(
285292 use_http = use_http ,
286293 )
287294
295+ logger .warning ("ALL GOOD" )
296+ raise BadRequest
288297 return document
289298
290299
0 commit comments