Skip to content

Commit

Permalink
Improve tool shed API error messages for repo path bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton committed Aug 5, 2024
1 parent 95c6650 commit da3a8a4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/galaxy/exceptions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,11 @@ class InconsistentDatabase(MessageException):
err_code = error_codes_by_name["INCONSISTENT_DATABASE"]


class InconsistentApplicationState(MessageException):
status_code = 500
err_code = error_codes_by_name["INCONSISTENT_APPLICATION_STATE"]


class InternalServerError(MessageException):
status_code = 500
err_code = error_codes_by_name["INTERNAL_SERVER_ERROR"]
Expand Down
5 changes: 5 additions & 0 deletions lib/galaxy/exceptions/error_codes.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,11 @@
"code": 500006,
"message": "Reference data required for program execution failed to load."
},
{
"name": "INCONSISTENT_APPLICATION_STATE",
"code": 500007,
"message": "Inconsistent application state (likely not dbms related) prevented fulfilling the request."
},
{
"name": "NOT_IMPLEMENTED",
"code": 501001,
Expand Down
5 changes: 5 additions & 0 deletions lib/tool_shed/managers/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from galaxy import exceptions
from galaxy.exceptions import (
InconsistentApplicationState,
InternalServerError,
ObjectNotFound,
RequestParameterInvalidException,
Expand Down Expand Up @@ -149,8 +150,12 @@ def _shed_tool_source_for(
if error_message:
raise InternalServerError("Failed to materialize target repository revision")
repo_files_dir = repository_metadata.repository.repo_path(trans.app)
if not repo_files_dir:
raise InconsistentApplicationState(f"Failed to resolve repository path from hgweb_config_manager for [{trs_tool_id}], inconsistent repository state or application configuration")
repo_rel_tool_path = relpath(tool_config, repo_files_dir)
path_to_tool = os.path.join(work_dir, repo_rel_tool_path)
if not os.path.exists(path_to_tool):
raise InconsistentApplicationState(f"Target tool expected at [{path_to_tool}] and not found, inconsistent repository state or application configuration")
tool_source = get_tool_source(path_to_tool)
return tool_source
finally:
Expand Down

0 comments on commit da3a8a4

Please sign in to comment.