diff --git a/cwltool/checker.py b/cwltool/checker.py index 317100af3..d7ccb1c89 100644 --- a/cwltool/checker.py +++ b/cwltool/checker.py @@ -406,27 +406,6 @@ def check_all_types( ) ) - if is_conditional_step(param_to_step, parm_id): - src_typ = aslist(srcs_of_sink[0]["type"]) - snk_typ = sink["type"] - - if "null" not in src_typ: - src_typ = ["null"] + cast(List[Any], src_typ) - - if "null" not in cast( - Union[List[str], CWLObjectType], snk_typ - ): # Given our type names this works even if not a list - validation["warning"].append( - SrcSink( - src_dict[parm_id], - sink, - linkMerge, - message="Source is from conditional step and may produce `null`", - ) - ) - - srcs_of_sink[0]["type"] = src_typ - for src in srcs_of_sink: check_result = check_types(src, sink, linkMerge, valueFrom) if check_result == "warning": diff --git a/cwltool/workflow.py b/cwltool/workflow.py index 986db5b99..7250b1ef4 100644 --- a/cwltool/workflow.py +++ b/cwltool/workflow.py @@ -359,6 +359,8 @@ def __init__( "SubworkflowFeatureRequirement not in requirements" ) + conditional = self.tool.get("when") + if "scatter" in self.tool: (feature, _) = self.get_requirement("ScatterFeatureRequirement") if not feature: @@ -398,11 +400,22 @@ def __init__( else: nesting = 1 - for _ in range(0, nesting): + for n in range(0, nesting): for oparam in outputparms: + if conditional and n == 0: + oparam["type"] = ["null"] + cast( + List[str], aslist(oparam["type"]) + ) oparam["type"] = {"type": "array", "items": oparam["type"]} self.tool["inputs"] = inputparms self.tool["outputs"] = outputparms + elif conditional: + # No scatter, but conditional + outputparms = copy.deepcopy(self.tool["outputs"]) + for oparam in outputparms: + oparam["type"] = ["null"] + cast(List[str], aslist(oparam["type"])) + self.tool["outputs"] = outputparms + self.prov_obj = None # type: Optional[ProvenanceProfile] if loadingContext.research_obj is not None: self.prov_obj = parentworkflowProv