Skip to content

Commit 12f0c8a

Browse files
committed
Ensure optional arrays only bind prefix if there are elements
1 parent 20d66e0 commit 12f0c8a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

wdlgen/task.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ def get_string(self):
109109
print("separate_array take preferences over: separator, default, true, false")
110110
if self.optional:
111111
# Ugly optional workaround: https://github.com/openwdl/wdl/issues/25#issuecomment-315424063
112-
internal_pref = f'if defined({name}) then "{bc}" else ""'
112+
# Additional workaround for 'length(select_first({name}, [])' as length requires a non-optional array
113+
internal_pref = f'if defined({name}) && length(select_first([{name}, []])) > 0 then "{bc}" else ""'
113114
return f'~{{{internal_pref}}}~{{sep=" {bc}" {name}}}'
114115
return f'~{{sep=" " prefix("{bc}", {name})}}'
115116

0 commit comments

Comments
 (0)