Skip to content

Commit 24034d5

Browse files
committed
patch default literal not valid from remote process
1 parent 49baba6 commit 24034d5

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

weaver/processes/convert.py

+19-1
Original file line numberDiff line numberDiff line change
@@ -1774,7 +1774,25 @@ def cwl2wps_io(io_info, io_select):
17741774
# anything later on when CWL/WPS merging is attempted
17751775
if io_def.symbols is not AnyValue:
17761776
kw["allowed_values"] = io_def.symbols
1777-
kw["default"] = io_info.get("default", None)
1777+
io_default = io_info.get("default", None)
1778+
# resilience against badly formed process descriptions
1779+
# (in case the reference is a remote process we have no control over)
1780+
if isinstance(io_default, list):
1781+
LOGGER.warning(
1782+
"Detected badly formed 'default' as array for literal input [%s]. "
1783+
"Attempting patch of the definition to make it valid.",
1784+
io_def.name,
1785+
)
1786+
if len(io_default) == 0:
1787+
io_default = None
1788+
elif len(io_default) == 1:
1789+
io_default = io_default[0]
1790+
if not isinstance(io_default, (str, float, int, bool, type(None))):
1791+
raise PackageTypeError(
1792+
f"Unsupported I/O info definition: '{io_info!r}' with '{io_select}' "
1793+
f"specifies a 'default' that does not correspond to a valid literal value."
1794+
)
1795+
kw["default"] = io_default
17781796
kw["min_occurs"] = io_def.min_occurs
17791797
kw["max_occurs"] = io_def.max_occurs
17801798
return io_literal(**kw)

0 commit comments

Comments
 (0)