cromwell icon indicating copy to clipboard operation
cromwell copied to clipboard

womtool thinks `if(select_first([foo == bar, bizz]) == bar)` is valid syntax

Open aofarrel opened this issue 1 year ago • 0 comments

You can use select_first() to coerce an optional variable into a not-optional variable. However, this copy error I made is definitely not valid:

# variant_caller.errorcode has type Array[String?]
# pass has type String
if(defined(variant_caller.errorcode)) {
   if(!(select_first([variant_caller.errorcode[0] == pass, "silly bogus fallback"]) == pass)) {
     # some code
} }

The syntax error is much more egregious than #7194, but it also isn't getting flagged by womtool, instead leading to an error at runtime.

"Failed to evaluate 'if_condition' (reason 1 of 1): Evaluating !((select_first([(variant_caller.errorcode[0] == pass), "silly bogus fallback"]) == pass)) failed: Sorry! Operation == is not supported on empty optional values. You might resolve this using select_first([optional, default]) to guarantee that you have a filled value."

You can make an argument that in a just world, #7194 is valid syntax due to it being in a codeblock that only runs if variant_caller.errorcode exists, and should cause neither a womtool nor runtime error. But an equality that isn't part of a quoted string probably never belongs in a select_first() array.

aofarrel avatar Aug 05 '23 00:08 aofarrel