Skip to content

Commit 13bfbeb

Browse files
author
Peter Amstutz
committed
Improve error handling of invalid workflow_engine_parameters
1 parent 4c03521 commit 13bfbeb

File tree

3 files changed

+35
-26
lines changed

3 files changed

+35
-26
lines changed

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
long_description = readmeFile.read()
1212

1313
setup(name='wes-service',
14-
version='3.2',
14+
version='3.3',
1515
description='GA4GH Workflow Execution Service reference implementation',
1616
long_description=long_description,
1717
author='GA4GH Containers and Workflows task team',

wes_service/arvados_wes.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,10 @@ def RunWorkflow(self, **args):
203203

204204
workflow_url = body.get("workflow_url")
205205

206-
project_uuid = body.get("workflow_engine_parameters", {}).get("project_uuid")
206+
workflow_engine_parameters = body.get("workflow_engine_parameters", {})
207+
project_uuid = None
208+
if workflow_engine_parameters:
209+
project_uuid = workflow_engine_parameters.get("project_uuid")
207210

208211
threading.Thread(target=self.invoke_cwl_runner, args=(cr["uuid"],
209212
workflow_url,

wes_service/util.py

+30-24
Original file line numberDiff line numberDiff line change
@@ -51,31 +51,37 @@ def collect_attachments(self, run_id=None):
5151
body = {}
5252
has_attachments = False
5353
for k, ls in iterlists(connexion.request.files):
54-
for v in ls:
55-
if k == "workflow_attachment":
56-
sp = v.filename.split("/")
57-
fn = []
58-
for p in sp:
59-
if p not in ("", ".", ".."):
60-
fn.append(secure_filename(p))
61-
dest = os.path.join(tempdir, *fn)
62-
if not os.path.isdir(os.path.dirname(dest)):
63-
os.makedirs(os.path.dirname(dest))
64-
self.log_for_run(run_id, "Staging attachment '%s' to '%s'" % (v.filename, dest))
65-
v.save(dest)
66-
has_attachments = True
67-
body[k] = "file://%s" % tempdir # Reference to temp working dir.
68-
elif k in ("workflow_params", "tags", "workflow_engine_parameters"):
69-
content = v.read()
70-
body[k] = json.loads(content.decode("utf-8"))
71-
else:
72-
body[k] = v.read().decode()
54+
try:
55+
for v in ls:
56+
if k == "workflow_attachment":
57+
sp = v.filename.split("/")
58+
fn = []
59+
for p in sp:
60+
if p not in ("", ".", ".."):
61+
fn.append(secure_filename(p))
62+
dest = os.path.join(tempdir, *fn)
63+
if not os.path.isdir(os.path.dirname(dest)):
64+
os.makedirs(os.path.dirname(dest))
65+
self.log_for_run(run_id, "Staging attachment '%s' to '%s'" % (v.filename, dest))
66+
v.save(dest)
67+
has_attachments = True
68+
body[k] = "file://%s" % tempdir # Reference to temp working dir.
69+
elif k in ("workflow_params", "tags", "workflow_engine_parameters"):
70+
content = v.read()
71+
body[k] = json.loads(content.decode("utf-8"))
72+
else:
73+
body[k] = v.read().decode()
74+
except Exception as e:
75+
raise ValueError("Error reading parameter '%s': %s" % (k, e))
7376
for k, ls in iterlists(connexion.request.form):
74-
for v in ls:
75-
if k in ("workflow_params", "tags", "workflow_engine_parameters"):
76-
body[k] = json.loads(v)
77-
else:
78-
body[k] = v
77+
try:
78+
for v in ls:
79+
if k in ("workflow_params", "tags", "workflow_engine_parameters") and v != "":
80+
body[k] = json.loads(v)
81+
else:
82+
body[k] = v
83+
except Exception as e:
84+
raise ValueError("Error reading parameter '%s': %s" % (k, e))
7985

8086
if "workflow_url" in body:
8187
if ":" not in body["workflow_url"]:

0 commit comments

Comments
 (0)