From 2ae80c9752e68f51a407c4c947bd5cec97d09414 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Thu, 1 Aug 2024 18:54:24 +0200 Subject: [PATCH] Improve relabel identifiers message when number of columns is not 2 Fixes https://github.com/galaxyproject/galaxy/issues/18633: ``` ValueError: dictionary update sequence element #4 has length 1; 2 is required File "galaxy/tools/__init__.py", line 1969, in handle_single_execution rval = self.execute( File "galaxy/tools/__init__.py", line 2066, in execute return self.tool_action.execute( File "galaxy/tools/actions/model_operations.py", line 89, in execute self._produce_outputs( File "galaxy/tools/actions/model_operations.py", line 120, in _produce_outputs tool.produce_outputs( File "galaxy/tools/__init__.py", line 3816, in produce_outputs new_labels_dict = dict(source_new_label) Exception caught while attempting to execute tool with id '__RELABEL_FROM_FILE__': ``` --- lib/galaxy/tools/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/galaxy/tools/__init__.py b/lib/galaxy/tools/__init__.py index 183955465055..065033fe3029 100644 --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -3812,8 +3812,14 @@ def add_copied_value_to_new_elements(new_label, dce_object): if how_type == "tabular": # We have a tabular file, where the first column is an existing element identifier, # and the second column is the new element identifier. + new_labels_dict = {} source_new_label = (line.strip().split("\t") for line in new_labels) - new_labels_dict = dict(source_new_label) + for i, label_pair in enumerate(source_new_label): + if not len(label_pair) == 2: + raise exceptions.MessageException( + f"Relabel mapping file line {i + 1} contains {len(label_pair)} columns, but 2 are required" + ) + new_labels_dict[label_pair[0]] = label_pair[1] for dce in hdca.collection.elements: dce_object = dce.element_object element_identifier = dce.element_identifier