@@ -49,6 +49,7 @@ def log_for_run(self, run_id, message):
4949 def collect_attachments (self , run_id = None ):
5050 tempdir = tempfile .mkdtemp ()
5151 body = {}
52+ has_attachments = False
5253 for k , ls in iterlists (connexion .request .files ):
5354 for v in ls :
5455 if k == "workflow_attachment" :
@@ -62,6 +63,7 @@ def collect_attachments(self, run_id=None):
6263 os .makedirs (os .path .dirname (dest ))
6364 self .log_for_run (run_id , "Staging attachment '%s' to '%s'" % (v .filename , dest ))
6465 v .save (dest )
66+ has_attachments = True
6567 body [k ] = "file://%s" % tempdir # Reference to temp working dir.
6668 elif k in ("workflow_params" , "tags" , "workflow_engine_parameters" ):
6769 content = v .read ()
@@ -77,9 +79,11 @@ def collect_attachments(self, run_id=None):
7779
7880 if "workflow_url" in body :
7981 if ":" not in body ["workflow_url" ]:
82+ if not has_attachments :
83+ raise ValueError ("Relative 'workflow_url' but missing 'workflow_attachment'" )
8084 body ["workflow_url" ] = "file://%s" % os .path .join (tempdir , secure_filename (body ["workflow_url" ]))
8185 self .log_for_run (run_id , "Using workflow_url '%s'" % body .get ("workflow_url" ))
8286 else :
83- raise Exception ("Missing 'workflow_url' in submission" )
87+ raise ValueError ("Missing 'workflow_url' in submission" )
8488
8589 return tempdir , body
0 commit comments