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

api_thumbnails ValueError for e.g. ?project=123x #44

Open
will-moore opened this issue Aug 15, 2024 · 0 comments
Open

api_thumbnails ValueError for e.g. ?project=123x #44

will-moore opened this issue Aug 15, 2024 · 0 comments

Comments

@will-moore
Copy link
Member

Going to e.g. /gallery-api/thumbnails/?project=123x
will give an error below.

Probably just needs a fix to check ids are valid numbers:

+++ b/idr_gallery/views.py
@@ -253,6 +253,11 @@ def api_thumbnails(request, conn=None, **kwargs):
     image_ids = {}
     for obj_type, ids in zip(['project', 'screen'], [project_ids, screen_ids]):
         for obj_id in ids:
+            try:
+                int(obj_id)
+            except ValueError:
+                logger.debug("api_thumbnails Invalid object ID %s" % obj_id)
+                continue
             images = _get_study_images(conn, obj_type, obj_id,
                                        tag_text="Study Example Image")

See https://www.openmicroscopy.org/qa2/qa/feedback/41897/

Traceback (most recent call last):

File "/opt/omero/web/venv3/lib64/python3.9/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)

File "/opt/omero/web/venv3/lib64/python3.9/site-packages/django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/opt/omero/web/venv3/lib64/python3.9/site-packages/omeroweb/decorators.py", line 597, in wrapper
context = f(request, *args, **kwargs)

File "/opt/omero/web/venv3/lib64/python3.9/site-packages/omeroweb/decorators.py", line 538, in wrapped
retval = f(request, *args, **kwargs)

File "/opt/omero/web/venv3/lib64/python3.9/site-packages/idr_gallery/views.py", line 256, in api_thumbnails
images = _get_study_images(conn, obj_type, obj_id,

File "/opt/omero/web/venv3/lib64/python3.9/site-packages/idr_gallery/views.py", line 207, in _get_study_images
params.addId(obj_id)

File "/opt/omero/web/venv3/lib64/python3.9/site-packages/omero_sys_ParametersI.py", line 335, in addId
self.addLong("id", rlong(id))

File "/opt/omero/web/venv3/lib64/python3.9/site-packages/omero/rtypes.py", line 216, in rlong
return RLongI(val)

File "/opt/omero/web/venv3/lib64/python3.9/site-packages/omero/rtypes.py", line 553, in __init__
omero.RLong.__init__(self, int(value))

ValueError: invalid literal for int() with base 10: '1801"'
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