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
"
}
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 returnsHttp404
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:A possible fix could be to actually raise a
Http404
exception instead of returning the type, or to add better detection injsonp
at https://github.com/ome/omero-web/blob/master/omeroweb/webgateway/views.py#L1503.