Skip to content

Commit

Permalink
Fix tool form building if select filters from unavailable dataset
Browse files Browse the repository at this point in the history
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:
```
        <param name="otu" type="data" format="mothur.list,mothur.shared" label="list or shared - OTU List of Shared"/>
        <param name="repfasta" type="data" format="fasta" optional="true" label="repfasta - rep.fasta" help="rep.fasta file generated by get.oturep"/>
        <param name="label" type="select" label="label - OTU Labels" optional="true" help="Select exactly one label. If none selected, first label in your list or shared file will be used">
            <options>
                <filter type="data_meta" ref="otu" key="labels"/>
            </options>
        </param>
```
but the first input collection to mothur.list or mothur.shared dataset
has no elements.
  • Loading branch information
mvdbeek committed Apr 8, 2024
1 parent c2f45dd commit 8616cbc
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lib/galaxy/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6854,14 +6854,23 @@ def touch(self):
if self.collection:
flag_modified(self.collection, "collection_type")

def to_hda_representative(self, multiple=False):
@overload
def to_hda_representative(self, multiple: Literal[False] = False) -> Optional[HistoryDatasetAssociation]: ...

@overload
def to_hda_representative(self, multiple: Literal[True]) -> List[HistoryDatasetAssociation]: ...

def to_hda_representative(
self, multiple: bool = False
) -> Union[List[HistoryDatasetAssociation], Optional[HistoryDatasetAssociation]]:
rval = []
for dataset in self.collection.dataset_elements:
rval.append(dataset.dataset_instance)
if multiple is False:
break
if len(rval) > 0:
return rval if multiple else rval[0]
if multiple:
return rval
return rval[0] if rval else None

def _serialize(self, id_encoder, serialization_options):
rval = dict_for(
Expand Down

0 comments on commit 8616cbc

Please sign in to comment.