@@ -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,7 +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 )
65- body [ k ] = "file://%s" % tempdir # Reference to temp working dir.
66+ has_attachments = True
6667 elif k in ("workflow_params" , "tags" , "workflow_engine_parameters" ):
6768 content = v .read ()
6869 body [k ] = json .loads (content .decode ("utf-8" ))
@@ -77,9 +78,11 @@ def collect_attachments(self, run_id=None):
7778
7879 if "workflow_url" in body :
7980 if ":" not in body ["workflow_url" ]:
81+ if not has_attachments :
82+ raise ValueError ("Relative 'workflow_url' but missing 'workflow_attachment'" )
8083 body ["workflow_url" ] = "file://%s" % os .path .join (tempdir , secure_filename (body ["workflow_url" ]))
8184 self .log_for_run (run_id , "Using workflow_url '%s'" % body .get ("workflow_url" ))
8285 else :
83- raise Exception ("Missing 'workflow_url' in submission" )
86+ raise ValueError ("Missing 'workflow_url' in submission" )
8487
8588 return tempdir , body
0 commit comments