Fix AttributeError when invalid tool ID passed to shed_tool_static

Return a 404 instead of crashing with an unhandled AttributeError when
toolbox.get_tool() returns None for an invalid/unknown tool GUID.

Fixes https://github.com/galaxyproject/galaxy/issues/22126
This commit is contained in:
mvdbeek
2026-03-28 10:31:51 +01:00
parent 3a56ddfc8f
commit 891a822491
@@ -2,7 +2,10 @@ import logging
import os
from galaxy import web
from galaxy.exceptions import RequestParameterInvalidException
from galaxy.exceptions import (
ObjectNotFound,
RequestParameterInvalidException,
)
from galaxy.util.path import (
join,
safe_contains,
@@ -34,6 +37,8 @@ class ShedToolStatic(BaseUIController):
"""
guid = "/".join((shed, "repos", owner, repo, tool, version))
tool = trans.app.toolbox.get_tool(guid)
if tool is None:
raise ObjectNotFound(f"Could not find tool with guid '{guid}'.")
repo_path = os.path.abspath(tool._repository_dir)
found_path = None