From ebeb081c16110169eda83bf41900a55d87bbc548 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Mon, 8 Apr 2024 12:57:45 +0200 Subject: [PATCH] Fix tool form building if select filters from unavailable dataset metadata Fixes: ``` Message Uncaught exception in exposed API method: Stack Trace(most recent call first) TypeError: 'NoneType' object is not iterable File "galaxy/web/framework/decorators.py", line 346, in decorator rval = func(self, trans, *args, **kwargs) File "galaxy/webapps/galaxy/api/tools.py", line 247, in build return tool.to_json(trans, kwd.get("inputs", kwd), history=history) File "galaxy/tools/__init__.py", line 2509, in to_json populate_state(request_context, self.inputs, params.__dict__, state_inputs, state_errors) File "galaxy/tools/parameters/__init__.py", line 412, in populate_state _populate_state_legacy( File "galaxy/tools/parameters/__init__.py", line 525, in _populate_state_legacy state[input.name] = input.get_initial_value(request_context, context) File "galaxy/tools/parameters/basic.py", line 1107, in get_initial_value options = list(self.get_options(trans, other_values)) File "galaxy/tools/parameters/basic.py", line 960, in get_options return self.options.get_options(trans, other_values) File "galaxy/tools/parameters/dynamic_options.py", line 893, in get_options rval = filter.filter_options(rval, trans, other_values) File "galaxy/tools/parameters/dynamic_options.py", line 227, in filter_options for r in ref: ``` from https://sentry.galaxyproject.org/share/issue/ac3a350198604034aca07eaca3cc9cb8/ This happens if you have the following input section: ``` ``` but there's no mothur.list or mothur.shared dataset in your history. --- lib/galaxy/tools/parameters/dynamic_options.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/galaxy/tools/parameters/dynamic_options.py b/lib/galaxy/tools/parameters/dynamic_options.py index fc7392cb5573..d618dcd9686d 100644 --- a/lib/galaxy/tools/parameters/dynamic_options.py +++ b/lib/galaxy/tools/parameters/dynamic_options.py @@ -217,6 +217,8 @@ def compare_meta_value(file_value, dataset_value): except ValueError: # not a valid dataset log.warning(f"could not filter by metadata: {self.ref_name} not a data or collection parameter") return [] + if ref is None: + return [] # get the metadata value. # - for lists: (of data sets) and collections the meta data values of all # elements is determined