From 7e11c57bd73a34cd729ae278ea779809b1155e33 Mon Sep 17 00:00:00 2001 From: Ahmed Awan Date: Tue, 14 Mar 2023 11:25:31 -0400 Subject: [PATCH] move type checking back to `parse_query_filters_with_relations` --- lib/galaxy/managers/history_contents.py | 25 +++++++++++--------- lib/galaxy_test/api/test_history_contents.py | 2 +- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/lib/galaxy/managers/history_contents.py b/lib/galaxy/managers/history_contents.py index 7de47a459d9..068020b63d5 100644 --- a/lib/galaxy/managers/history_contents.py +++ b/lib/galaxy/managers/history_contents.py @@ -532,7 +532,20 @@ class HistoryContentsFilters( def parse_query_filters_with_relations(self, query_filters: ValueFilterQueryParams, history_id): """Parse query filters but consider case where related filter is included.""" has_related_q = [q for q in ("related-eq", "related") if query_filters.q and q in query_filters.q] - if has_related_q: + if query_filters.q and query_filters.qv and has_related_q: + qv_index = query_filters.q.index(has_related_q[0]) + qv_hid = query_filters.qv[qv_index] + + # Type check whether hid is int + if not qv_hid.isdigit(): + raise glx_exceptions.RequestParameterInvalidException( + "unparsable value for related filter", + column="related", + operation="eq", + value=qv_hid, + ValueError="invalid type in filter", + ) + query_filters_with_relations = self.get_query_filters_with_relations( query_filters=query_filters, related_q=has_related_q[0], history_id=history_id ) @@ -599,16 +612,6 @@ class HistoryContentsFilters( qv_index = query_filters.q.index(related_q) qv_hid = query_filters.qv[qv_index] - # Type check whether hid is int - if not qv_hid.isdigit(): - raise glx_exceptions.RequestParameterInvalidException( - "unparsable value for related filter", - column="related", - operation="eq", - value=qv_hid, - ValueError="invalid type in filter", - ) - # Make new q and qv excluding related filter new_q = [x for i, x in enumerate(query_filters.q) if i != qv_index] new_qv = [x for i, x in enumerate(query_filters.qv) if i != qv_index] diff --git a/lib/galaxy_test/api/test_history_contents.py b/lib/galaxy_test/api/test_history_contents.py index 8f5cc22883b..f92bdd4577f 100644 --- a/lib/galaxy_test/api/test_history_contents.py +++ b/lib/galaxy_test/api/test_history_contents.py @@ -746,7 +746,7 @@ class TestHistoryContentsApi(ApiTestCase): # Run tool on first dataset to get 3rd, related dataset inputs = { "input1": {"src": "hda", "id": input_hda_id}, - "sleep_time": 10, + "sleep_time": 0, } run_response = self.dataset_populator.run_tool_raw( "cat_data_and_sleep",