diff --git a/lib/galaxy/tool_util/toolbox/base.py b/lib/galaxy/tool_util/toolbox/base.py index 4529f85d40db..4742e7b7c32f 100644 --- a/lib/galaxy/tool_util/toolbox/base.py +++ b/lib/galaxy/tool_util/toolbox/base.py @@ -96,7 +96,12 @@ def __init__(self, toolbox: "AbstractToolBox"): def has_tool(self, tool_id: str) -> bool: toolbox = self.__toolbox - return tool_id in toolbox._tools_by_id or tool_id in toolbox._tools_by_old_id + # tool_id could be full guid, old tool id (no toolshed and version info) or versionless guid. + return ( + tool_id in toolbox._tools_by_id + or tool_id in toolbox._tools_by_old_id + or bool(toolbox._lineage_map.lineage_map.get(tool_id)) + ) def get_tool(self, tool_id: str): return self.__toolbox.get_tool(tool_id) diff --git a/lib/galaxy/tool_util/toolbox/lineages/factory.py b/lib/galaxy/tool_util/toolbox/lineages/factory.py index 96efb51d77d1..2a68c32b2ee4 100644 --- a/lib/galaxy/tool_util/toolbox/lineages/factory.py +++ b/lib/galaxy/tool_util/toolbox/lineages/factory.py @@ -44,7 +44,15 @@ def get(self, tool_id) -> Optional[ToolLineage]: if lineage: return lineage if tool_id not in self.lineage_map: - tool = self.app.toolbox._tools_by_id.get(tool_id) + toolbox = None + try: + toolbox = self.app.toolbox + except AttributeError: + # We're building the lineage map while building the toolbox, + # so app.toolbox may not be available. + # TODO: is the fallback really needed / can it be fixed by improving _get_versionless ? + pass + tool = toolbox and toolbox._tools_by_id.get(tool_id) if tool: lineage = ToolLineage.from_tool(tool) if lineage: