Files
galaxy/test/functional/tools/expression_text_to_bool.xml
mvdbeek aead68b0a1 Fix NoReplacement handling in workflow callback_helper
When an optional text parameter is omitted from a workflow invocation and
connected to an expression tool, the callback_helper in visit_input_values
could fail to replace unresolved inputs with the tool parameter default.

Two issues contributed to this:

1. NoReplacement doesn't implement __eq__, so when the callback returns a
   different NoReplacement instance than the module-level NO_REPLACEMENT
   singleton, the equality comparison fails and the raw NoReplacement
   object gets stored as the input value.

2. The replace_optional_connections path needs to guard replacements with
   is_runtime_value(value) to avoid clobbering valid tool-state values
   for unconnected parameters (like select parameters with defaults).

Fix both by switching all NoReplacement comparisons to isinstance()
checks and restoring the is_runtime_value guard. Add a framework workflow
test that connects an optional text parameter to an expression tool
converting text→boolean, then uses the boolean as a when condition.
2026-03-06 17:23:32 +01:00

28 lines
876 B
XML

<tool name="expression_text_to_bool" id="expression_text_to_bool" version="0.1.0" tool_type="expression">
<expression type="ecma5.1">
{
var value = $job.text_input;
if (value == "false" || value == "False") {
return {'bool_out': false};
}
return {'bool_out': !!value};
}
</expression>
<inputs>
<param type="text" label="Text input." name="text_input" />
</inputs>
<outputs>
<output type="boolean" name="bool_out" from="bool_out" />
</outputs>
<tests>
<test>
<param name="text_input" value="hello" />
<output name="bool_out" value_json="true" />
</test>
<test>
<param name="text_input" value="" />
<output name="bool_out" value_json="false" />
</test>
</tests>
</tool>