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.1] Increase API robustness to invalid requests, improve compressed data serving #18494

Merged

Conversation

mvdbeek
Copy link
Member

@mvdbeek mvdbeek commented Jul 4, 2024

See the commits for descriptions

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.

mvdbeek added 2 commits July 4, 2024 10:46
I suspect a state bug in the tool form code is the issue here and the id
refers to a HDA id, but this is a solid fix anyway if someone submits
wrong values via the API.
Fixes galaxyproject#18485:
```
Stack Trace

Newest

AssertionError: null
  File "galaxy/web/framework/decorators.py", line 346, in decorator
    rval = func(self, trans, *args, **kwargs)
  File "galaxy/webapps/galaxy/api/tools.py", line 247, in build
    return tool.to_json(trans, kwd.get("inputs", kwd), history=history)
  File "galaxy/tools/__init__.py", line 2510, in to_json
    populate_state(request_context, self.inputs, params.__dict__, state_inputs, state_errors)
  File "galaxy/tools/parameters/__init__.py", line 412, in populate_state
    _populate_state_legacy(
  File "galaxy/tools/parameters/__init__.py", line 625, in _populate_state_legacy
    check_param(request_context, input, param_value, context, simple_errors=simple_errors)
  File "galaxy/tools/parameters/__init__.py", line 246, in check_param
    value = param.from_json(value, trans, param_values)
  File "galaxy/tools/parameters/basic.py", line 2132, in from_json
    value = self.to_python(value, trans.app)
  File "galaxy/tools/parameters/basic.py", line 1963, in to_python
    return history_item_dict_to_python(value["values"][0], app, self.name)
  File "galaxy/tools/parameters/basic.py", line 2799, in history_item_dict_to_python
    return src_id_to_item(sa_session=app.model.context, security=app.security, value=value)
  File "galaxy/tools/parameters/basic.py", line 2056, in src_id_to_item
    assert item
```
mvdbeek added 2 commits July 4, 2024 11:40
We were mostly doing this already. Also raises an exception in
`text_data` if content is not decodable.

Fixes
https://sentry.galaxyproject.org/share/issue/b826c0be95a4424e8b1d63983255f23d/:
```
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
  File "galaxy/web/framework/middleware/error.py", line 167, in __call__
    app_iter = self.application(environ, sr_checker)
  File "galaxy/web/framework/middleware/statsd.py", line 29, in __call__
    req = self.application(environ, start_response)
  File "/cvmfs/main.galaxyproject.org/venv/lib/python3.11/site-packages/paste/httpexceptions.py", line 635, in __call__
    return self.application(environ, start_response)
  File "galaxy/web/framework/base.py", line 174, in __call__
    return self.handle_request(request_id, path_info, environ, start_response)
  File "galaxy/web/framework/base.py", line 263, in handle_request
    body = method(trans, **kwargs)
  File "galaxy/webapps/galaxy/controllers/dataset.py", line 152, in display
    display_data, headers = data.datatype.display_data(
  File "galaxy/datatypes/tabular.py", line 199, in display_data
    truncated_data=open(dataset.get_file_name()).read(max_peek_size),
  File "<frozen codecs>", line 322, in decode
```
Fixes https://sentry.galaxyproject.org/share/issue/e2c535d2d4904d438a0a1524c991bba4/:
```
UnicodeEncodeError: 'ascii' codec can't encode characters in position 14-16: ordinal not in range(128)
  File "galaxy/web/framework/middleware/error.py", line 167, in __call__
    app_iter = self.application(environ, sr_checker)
  File "galaxy/web/framework/middleware/statsd.py", line 34, in __call__
    self.galaxy_stasd_client.timing(page, dt)
  File "galaxy/web/statsd_client.py", line 35, in timing
    self.statsd_client.timing(infix + path, time)
  File "statsd/client/base.py", line 33, in timing
    self._send_stat(stat, '%0.6f|ms' % delta, rate)
  File "statsd/client/base.py", line 61, in _send_stat
    self._after(self._prepare(stat, value, rate))
  File "statsd/client/base.py", line 76, in _after
    self._send(data)
  File "statsd/client/udp.py", line 42, in _send
    self._sock.sendto(data.encode('ascii'), self._addr)
```
Copy link
Contributor

@davelopez davelopez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They look like solid fixes. Thank you!

@mvdbeek mvdbeek merged commit 21e7a22 into galaxyproject:release_24.1 Jul 5, 2024
47 of 49 checks passed
@galaxyproject-sentryintegration

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ TemplateLookupException: Can't locate template for uri '/dataset/large_file.mako' https://127.0.0.1:8080/datasets/f9cad7b01a47213... View Issue
  • ‼️ TopLevelLookupException: Can't locate template for uri '/dataset/large_file.mako' https://127.0.0.1:8080/datasets/f9cad7b01a47213... View Issue

Did you find this useful? React with a 👍 or 👎

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.

2 participants