From 3aaecbe65dadce9ab3ec406252663ac2b93e98a9 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Sat, 4 Jul 2026 12:33:57 +0200 Subject: [PATCH] index reload: refresh the entries behind already-registered stubs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _register_new_index_entries_as_stubs skipped every tool already in _tools_by_id, so a stub minted from an install-time ad-hoc entry kept serving that metadata-poor entry after the conf-driven populate enriched the index — the fastp panel payload was missing tool_shed_repository (test_only_latest_version_in_panel_fastp). Swap the entry behind the existing stub instead: the panel and registries hold the stub object, and _overrides survive. --- lib/galaxy/tools/lazy_toolbox.py | 12 +++++++++++- test/unit/app/tools/test_lazy_tool.py | 12 ++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/galaxy/tools/lazy_toolbox.py b/lib/galaxy/tools/lazy_toolbox.py index 497edc6fe04..e1d9ad75d27 100644 --- a/lib/galaxy/tools/lazy_toolbox.py +++ b/lib/galaxy/tools/lazy_toolbox.py @@ -1052,7 +1052,17 @@ class LazyToolBox(ToolBox): if self._tool_index is None: return for tool_id, entry in self._tool_index.entries.items(): - if tool_id in self._tools_by_id: + # ``Any``: the registry is typed for real Tools but holds + # LazyTool stubs on this toolbox (same duck-typing as create_tool). + existing: Any = self._tools_by_id.get(tool_id) + if existing is not None: + if isinstance(existing, LazyTool) and existing._entry is not entry: + # Refresh the stub in place — the panel and registries + # hold this object, and the reloaded index may carry an + # enriched entry (e.g. the conf-driven populate after a + # shed install adds repository metadata the install-time + # ad-hoc entry lacked). ``_overrides`` survive. + existing._entry = entry continue try: self._register_lazy_entry(entry) diff --git a/test/unit/app/tools/test_lazy_tool.py b/test/unit/app/tools/test_lazy_tool.py index a8a3d6df11c..289ef621b52 100644 --- a/test/unit/app/tools/test_lazy_tool.py +++ b/test/unit/app/tools/test_lazy_tool.py @@ -366,6 +366,18 @@ def test_create_tool_stamps_data_manager_conf_id_on_entry(): box._store.update_index_entry.assert_called_once_with(e) +def test_index_reload_refreshes_existing_stub_entries(): + box = _seam_box() + stale = _entry(id="fastp_guid") + stub = _stub(stale) + box._tools_by_id = {"fastp_guid": stub} + enriched = _entry(id="fastp_guid", tool_shed="toolshed.example.com", repository_name="fastp") + box._tool_index.entries["fastp_guid"] = enriched + box._register_new_index_entries_as_stubs() + assert stub._entry is enriched + assert stub.to_panel_entry()["tool_shed_repository"]["name"] == "fastp" + + def test_create_tool_raises_on_index_miss(): # The populator owns the index — including the Galaxy-internal lib # tools listed in ``galaxy.tools.special_tools.hidden_lib_tool_paths``.