Skip to content

Commit df879c6

Browse files
authored
Merge pull request #22546 from mvdbeek/merge-collection-fix
[26.0] Fix crash merging structurally invalid nested collections
2 parents 88b4329 + 5572aa4 commit df879c6

2 files changed

Lines changed: 20 additions & 4 deletions

File tree

lib/galaxy/managers/collections.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -638,10 +638,7 @@ def __recursively_create_collections_for_elements(
638638

639639
new_elements = {}
640640
for key, element in elements.items():
641-
if isinstance(element, DatasetCollection):
642-
continue
643-
644-
if element.get("src") != "new_collection":
641+
if not isinstance(element, dict) or element.get("src") != "new_collection":
645642
continue
646643

647644
# element is a dict with src new_collection and

lib/galaxy_test/api/test_tools.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from galaxy_test.base import rules_test_data
2424
from galaxy_test.base.api_asserts import (
2525
assert_error_code_is,
26+
assert_error_message_contains,
2627
assert_file_looks_like_xlsx,
2728
assert_has_keys,
2829
assert_status_code_is,
@@ -810,6 +811,24 @@ def test_zip_list_inputs(self):
810811
)
811812
assert zipped_hdca["collection_type"] == "list:paired"
812813

814+
@skip_without_tool("__MERGE_COLLECTION__")
815+
def test_merge_collection_rejects_structurally_invalid_inputs(self):
816+
with self.dataset_populator.test_history(require_new=False) as history_id:
817+
list_paired_id = self.dataset_collection_populator.create_list_of_pairs_in_history(
818+
history_id, wait=True
819+
).json()["outputs"][0]["id"]
820+
plain_list_id = self.dataset_collection_populator.create_list_in_history(
821+
history_id, contents=["a", "b"], wait=True
822+
).json()["outputs"][0]["id"]
823+
self.dataset_populator.wait_for_history(history_id, assert_ok=True)
824+
inputs = {
825+
"inputs_0|input": {"src": "hdca", "id": list_paired_id},
826+
"inputs_1|input": {"src": "hdca", "id": plain_list_id},
827+
}
828+
response = self._run("__MERGE_COLLECTION__", history_id, inputs, assert_ok=False)
829+
assert_status_code_is(response, 400)
830+
assert_error_message_contains(response, "must be a sub-collection")
831+
813832
@skip_without_tool("__EXTRACT_DATASET__")
814833
@skip_without_tool("cat_data_and_sleep")
815834
def test_database_operation_tool_with_pending_inputs(self):

0 commit comments

Comments
 (0)