From 41defa80ac33ba37cde28401a99470029607374f Mon Sep 17 00:00:00 2001 From: Wolfgang Maier Date: Sat, 24 Feb 2024 09:48:33 +0100 Subject: [PATCH] Make cleaning of request params profile-dependent as suggested by @martenson --- lib/galaxy/tool_util/xsd/galaxy.xsd | 1 + lib/galaxy/tools/__init__.py | 7 +++++++ lib/galaxy/webapps/galaxy/controllers/async.py | 2 +- lib/galaxy/webapps/galaxy/controllers/tool_runner.py | 2 +- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/galaxy/tool_util/xsd/galaxy.xsd b/lib/galaxy/tool_util/xsd/galaxy.xsd index 3ad702ce7492..812e80198194 100644 --- a/lib/galaxy/tool_util/xsd/galaxy.xsd +++ b/lib/galaxy/tool_util/xsd/galaxy.xsd @@ -68,6 +68,7 @@ List of behavior changes associated with profile versions: ### 24.0 - Do not use Galaxy python environment for `data_source_async` tools. +- Drop request parameters received by data source tools that are not declared in `` section. ### Examples diff --git a/lib/galaxy/tools/__init__.py b/lib/galaxy/tools/__init__.py index a8e926bd5f75..d75aed1b09f6 100644 --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -2895,6 +2895,13 @@ class DataSourceTool(OutputParameterJSONTool): tool_type = "data_source" default_tool_action = DataSourceToolAction + @property + def wants_params_cleaned(self): + """Indicates whether received, but undeclared request params should be cleaned.""" + if self.profile < 24.0: + return False + return True + def _build_GALAXY_URL_parameter(self): return ToolParameter.build( self, XML(f'') diff --git a/lib/galaxy/webapps/galaxy/controllers/async.py b/lib/galaxy/webapps/galaxy/controllers/async.py index d9ecae7f2305..4a9615fc700d 100644 --- a/lib/galaxy/webapps/galaxy/controllers/async.py +++ b/lib/galaxy/webapps/galaxy/controllers/async.py @@ -86,7 +86,7 @@ def index(self, trans, tool_id=None, data_secret=None, **kwd): translator.galaxy_name for translator in tool.input_translator.param_trans_dict.values() } for param in params: - if param in tool_declared_params: + if param in tool_declared_params or not tool.wants_params_cleaned: params_dict[param] = params.get(param, None) params = params_dict diff --git a/lib/galaxy/webapps/galaxy/controllers/tool_runner.py b/lib/galaxy/webapps/galaxy/controllers/tool_runner.py index 23fa8f44fa36..f85e9b2d9a30 100644 --- a/lib/galaxy/webapps/galaxy/controllers/tool_runner.py +++ b/lib/galaxy/webapps/galaxy/controllers/tool_runner.py @@ -93,7 +93,7 @@ def __tool_404__(): # preserve original params sent by the remote server as extra dict # before in-place translation happens, then clean the incoming params params.update({"incoming_request_params": params.copy()}) - if tool.input_translator: + if tool.input_translator and tool.wants_params_cleaned: for k in list(params.keys()): if k not in tool.input_translator.vocabulary and k not in ("URL", "incoming_request_params"): # the remote server has sent a param