From 5ce49867520edf99a2d66d4876aac488e9acb167 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Wed, 17 Apr 2024 16:39:54 +0200 Subject: [PATCH] Avoid exception when opening apply rules tool and no collection in history Fixes https://sentry.galaxyproject.org/share/issue/97b5b9cfcef14ca0b59b851684170698/ ``` AttributeError: 'NoneType' object has no attribute 'id' File "galaxy/tools/__init__.py", line 2601, in populate_model tool_dict = input.to_dict(request_context, other_values=other_values) File "galaxy/tools/parameters/basic.py", line 2648, in to_dict "id": trans.app.security.encode_id(target.id), ``` Which is in a try/except anyway, so fairly inconsequential, but results in cleaner logs / one less sentry error. --- lib/galaxy/tools/parameters/basic.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/galaxy/tools/parameters/basic.py b/lib/galaxy/tools/parameters/basic.py index e24904731ae..62b29613d1f 100644 --- a/lib/galaxy/tools/parameters/basic.py +++ b/lib/galaxy/tools/parameters/basic.py @@ -2646,8 +2646,7 @@ class RulesListToolParameter(BaseJsonToolParameter): def to_dict(self, trans, other_values=None): other_values = other_values or {} d = ToolParameter.to_dict(self, trans) - if (target_name := self.data_ref) in other_values: - target = other_values[target_name] + if target := other_values.get(self.data_ref): if not is_runtime_value(target): d["target"] = { "src": "hdca" if hasattr(target, "collection") else "hda",