From 040918f766bc479f23756fd374df3a7cb97d2df0 Mon Sep 17 00:00:00 2001 From: Ernest Provo Date: Fri, 27 Mar 2026 21:59:52 -0400 Subject: [PATCH] Fix IndexError in SplitPairedAndUnpairedTool for unpaired elements The list:paired_or_unpaired branch in produce_outputs used history_content_type == "dataset" to distinguish paired from unpaired elements. This check is always False because even singletons are wrapped in sub-collections, so all elements were routed to _handle_paired which crashes on elements[1] for 1-element collections. Replace the history_content_type check with element count inspection on the sub-collection. Also unwrap singletons in _handle_unpaired since the assert there fails for the same reason. Fixes #22204 --- lib/galaxy/tools/__init__.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/galaxy/tools/__init__.py b/lib/galaxy/tools/__init__.py index 921f02ba3b3..a511573a7cd 100644 --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -4036,8 +4036,12 @@ class SplitPairedAndUnpairedTool(DatabaseOperationTool): def _handle_unpaired(dce): element_identifier = dce.element_identifier - assert getattr(dce.element_object, "history_content_type", None) == "dataset" - copied_value = dce.element_object.copy(copy_tags=dce.element_object.tags, flush=False) + element_object = dce.element_object + # In list:paired_or_unpaired collections, unpaired elements are + # wrapped in a 1-element sub-collection. Unwrap to get the dataset. + if getattr(element_object, "history_content_type", None) != "dataset": + element_object = element_object.elements[0].element_object + copied_value = element_object.copy(copy_tags=element_object.tags, flush=False) unpaired_dce_copies[element_identifier] = copied_value unpaired_dce_columns[element_identifier] = dce.columns @@ -4057,7 +4061,8 @@ class SplitPairedAndUnpairedTool(DatabaseOperationTool): _handle_paired(element) elif collection_type == "list:paired_or_unpaired": for element in collection.elements: - if getattr(element.element_object, "history_content_type", None) == "dataset": + sub_collection = element.element_object + if len(sub_collection.elements) == 1: _handle_unpaired(element) else: _handle_paired(element)