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

Problem with jsonp wrapper and missing plate #506

Open
knabar opened this issue Oct 26, 2023 · 0 comments
Open

Problem with jsonp wrapper and missing plate #506

knabar opened this issue Oct 26, 2023 · 0 comments

Comments

@knabar
Copy link
Member

knabar commented Oct 26, 2023

This issue may be more generic, but I ran into it when accidentally requesting a plate that does not exist via /webgateway/plate/999999/0/.

The plateGrid_json method returns Http404 when a plate is not found at https://github.com/ome/omero-web/blob/master/omeroweb/webgateway/views.py#L1702.

The jsonp wrapper does not recognize this as a non-JSON response, which results in an error result such as:

{
message: "Object of type type is not JSON serializable",
stacktrace: "Traceback (most recent call last):
  File "/opt/v2-demo-dev/venv38/lib64/python3.8/site-packages/omeroweb/webgateway/views.py", line 1517, in wrap
    return JsonResponse(rv, safe=safe)
  File "/opt/v2-demo-dev/venv38/lib64/python3.8/site-packages/django/http/response.py", line 731, in __init__
    data = json.dumps(data, cls=encoder, **json_dumps_params)
  File "/opt/rh/rh-python38/root/usr/lib64/python3.8/json/__init__.py", line 234, in dumps
    return cls(
  File "/opt/rh/rh-python38/root/usr/lib64/python3.8/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/opt/rh/rh-python38/root/usr/lib64/python3.8/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/opt/v2-demo-dev/venv38/lib64/python3.8/site-packages/django/core/serializers/json.py", line 106, in default
    return super().default(o)
  File "/opt/rh/rh-python38/root/usr/lib64/python3.8/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type type is not JSON serializable
"
}

A possible fix could be to actually raise a Http404 exception instead of returning the type, or to add better detection in jsonp at https://github.com/ome/omero-web/blob/master/omeroweb/webgateway/views.py#L1503.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant