diff --git a/lib/galaxy/tools/actions/__init__.py b/lib/galaxy/tools/actions/__init__.py index 50429437766..3088a070043 100644 --- a/lib/galaxy/tools/actions/__init__.py +++ b/lib/galaxy/tools/actions/__init__.py @@ -941,8 +941,12 @@ class DefaultToolAction(ToolAction): for input_name in inp_data: data = inp_data[input_name] + # Skip collection inputs and any suffixed dataset names derived from them (e.g., "datasets1", "datasets2") if input_name in inp_dataset_collections: continue + # Also skip if the name starts with a collection input key and the remainder is a numeric suffix + if any(input_name.startswith(key) and input_name[len(key) :].isdigit() for key in inp_dataset_collections): + continue if getattr(data, "hid", None): input_hids.append(data.hid) return on_text_for_dataset_and_collections(dataset_hids=input_hids, collection_hids=collection_hids) diff --git a/test/unit/app/tools/test_actions.py b/test/unit/app/tools/test_actions.py index de6efdca29d..d6ec06b4412 100644 --- a/test/unit/app/tools/test_actions.py +++ b/test/unit/app/tools/test_actions.py @@ -51,6 +51,18 @@ TWO_OUTPUTS = """ """ +# Tool with a multiple="true" data parameter – used to test on_string handling for collections. +MULTIPLE_DATA_TOOL = """ + cat "$param1" < $out1 + + + + + + + +""" + def test_on_text_for_numeric_ids(): def assert_on_text_is(expected, hids): @@ -83,6 +95,27 @@ def test_on_text_for_dataset_and_collections(): class TestDefaultToolAction(TestCase, tools_support.UsesTools): + def test_on_text_multiple_true_collection(self): + # Create a collection with three datasets + hdca = model.HistoryDatasetCollectionAssociation() + hdca.id = 999 + hdca.hid = 55 + collection = model.DatasetCollection() + hdca.collection = collection + # add three datasets to the collection + hda1 = self.__add_dataset() + hda2 = self.__add_dataset() + hda3 = self.__add_dataset() + model.DatasetCollectionElement(collection=collection, element=hda1) + model.DatasetCollectionElement(collection=collection, element=hda2) + model.DatasetCollectionElement(collection=collection, element=hda3) + collection.collection_type = "list" + self.history.dataset_collections.append(hdca) + # incoming param with the collection + incoming = {"param1": hdca} + job, output = self._simple_execute(contents=MULTIPLE_DATA_TOOL, incoming=incoming) + assert output["out1"].name == f"Test Tool on collection {hdca.hid}" + def setUp(self): self.setup_app() history = model.History()