Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[24.2] Serialize message exceptions on execution error #19483

Conversation

mvdbeek
Copy link
Member

@mvdbeek mvdbeek commented Jan 29, 2025

This fixes handling of ToolInputsNotOK exceptions, which would fail with

Message
Uncaught exception in exposed API method:
Stack Trace

Newest

TypeError: Object of type ToolInputsNotOKException is not JSON serializable
  File "galaxy/util/json.py", line 74, in safe_dumps
    dumped = json.dumps(obj, allow_nan=False, **kwargs)
  File "__init__.py", line 238, in dumps
    **kw).encode(obj)
  File "json/encoder.py", line 200, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "json/encoder.py", line 258, in iterencode
    return _iterencode(o, 0)
  File "json/encoder.py", line 180, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type ToolInputsNotOKException is not JSON serializable
  File "galaxy/web/framework/decorators.py", line 350, in decorator
    rval = format_return_as_json(rval, jsonp_callback, pretty=trans.debug)
  File "galaxy/web/framework/decorators.py", line 387, in format_return_as_json
    json = safe_dumps(rval, **dumps_kwargs)
  File "galaxy/util/json.py", line 77, in safe_dumps
    dumped = json.dumps(obj, allow_nan=False, **kwargs)
  File "__init__.py", line 238, in dumps
    **kw).encode(obj)
  File "json/encoder.py", line 200, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "json/encoder.py", line 258, in iterencode
    return _iterencode(o, 0)
  File "json/encoder.py", line 180, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '

This also required making the tool form error modal dependent on the returned errors, instead of only popping up on non-200 status codes or if all jobs failed.

That's what submitting the Tag elements tool that requires datasets in OK state looks like if one dataset is in failed_metadata state.
Screenshot 2025-01-29 at 18 15 27
This is much better than the just showing the API request as we used to do, and all the info is there for the UI team to show exactly which dataset is at fault.

Fixes #19482

How to test the changes?

(Select all options that apply)

  • I've included appropriate automated tests.
  • This is a refactoring of components with existing test coverage.
  • Instructions for manual testing are as follows:
    1. [add testing steps and prerequisites here if you didn't write automated tests covering all your changes]

License

  • I agree to license these and all my past contributions to the core galaxy codebase under the MIT license.

@github-actions github-actions bot added this to the 25.0 milestone Jan 29, 2025
@mvdbeek mvdbeek force-pushed the fix_tool_input_not_exception_handling branch from b59e9ea to a020ddd Compare January 30, 2025 08:43
This fixes handling of `ToolInputsNotOK` exceptions, which would fail
with
```
Message
Uncaught exception in exposed API method:
Stack Trace

Newest

TypeError: Object of type ToolInputsNotOKException is not JSON serializable
  File "galaxy/util/json.py", line 74, in safe_dumps
    dumped = json.dumps(obj, allow_nan=False, **kwargs)
  File "__init__.py", line 238, in dumps
    **kw).encode(obj)
  File "json/encoder.py", line 200, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "json/encoder.py", line 258, in iterencode
    return _iterencode(o, 0)
  File "json/encoder.py", line 180, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type ToolInputsNotOKException is not JSON serializable
  File "galaxy/web/framework/decorators.py", line 350, in decorator
    rval = format_return_as_json(rval, jsonp_callback, pretty=trans.debug)
  File "galaxy/web/framework/decorators.py", line 387, in format_return_as_json
    json = safe_dumps(rval, **dumps_kwargs)
  File "galaxy/util/json.py", line 77, in safe_dumps
    dumped = json.dumps(obj, allow_nan=False, **kwargs)
  File "__init__.py", line 238, in dumps
    **kw).encode(obj)
  File "json/encoder.py", line 200, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "json/encoder.py", line 258, in iterencode
    return _iterencode(o, 0)
  File "json/encoder.py", line 180, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
```

This also required making the tool form error modal dependent on the
returned errors, instead of only popping up on non-200 status codes
or if all jobs failed.

Fixes galaxyproject#19482
@mvdbeek mvdbeek force-pushed the fix_tool_input_not_exception_handling branch from a020ddd to ec576b8 Compare January 30, 2025 08:44
@mvdbeek
Copy link
Member Author

mvdbeek commented Jan 30, 2025

Test errors are all unrelated

@mvdbeek mvdbeek requested a review from a team January 30, 2025 14:04
@mvdbeek mvdbeek merged commit e4c1172 into galaxyproject:release_24.2 Jan 30, 2025
50 of 55 checks passed
@jdavcs jdavcs modified the milestones: 25.0, 24.2 Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants