Project-MONAI / Project-MONAI/MONAILabel

Monailabel-Plugin in XNAT OHIF Viewer status code 500

Open
#1,837 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
891
Forks
269
Avg merge
15h 41m
Merged PRs (30d)
1

Description

Describe the bug
Open Monailabel Plugin from XNAT OHIF Viewer shows a http status code 500. Debugging reveals a 401 when trying to get all XNAT projects over the XNAT api in xnat.py.

Server logs
OHIF error:

GET https://xnat.<...>.ch/info/ 500 (Internal Server Error)
(anonymous) @ vendors~app.bundle.6ca4aaacffe42287ff12.js:2
e.exports @ vendors~app.bundle.6ca4aaacffe42287ff12.js:2
e.exports @ vendors~app.bundle.6ca4aaacffe42287ff12.js:2
Promise.then
s.request @ vendors~app.bundle.6ca4aaacffe42287ff12.js:2
a.forEach.s.<computed> @ vendors~app.bundle.6ca4aaacffe42287ff12.js:2
(anonymous) @ vendors~app.bundle.6ca4aaacffe42287ff12.js:2
_E @ app.bundle.aef1aaedd2166485be4f.js:1
(anonymous) @ app.bundle.aef1aaedd2166485be4f.js:1
c @ vendors~app.bundle.6ca4aaacffe42287ff12.js:2
(anonymous) @ vendors~app.bundle.6ca4aaacffe42287ff12.js:2
(anonymous) @ vendors~app.bundle.6ca4aaacffe42287ff12.js:2
Ii @ app.bundle.aef1aaedd2166485be4f.js:1
E @ app.bundle.aef1aaedd2166485be4f.js:1
(anonymous) @ app.bundle.aef1aaedd2166485be4f.js:1
(anonymous) @ app.bundle.aef1aaedd2166485be4f.js:1
(anonymous) @ app.bundle.aef1aaedd2166485be4f.js:1
(anonymous) @ app.bundle.aef1aaedd2166485be4f.js:1
c @ vendors~app.bundle.6ca4aaacffe42287ff12.js:2
(anonymous) @ vendors~app.bundle.6ca4aaacffe42287ff12.js:2
(anonymous) @ vendors~app.bundle.6ca4aaacffe42287ff12.js:2
ti @ app.bundle.aef1aaedd2166485be4f.js:1
E @ app.bundle.aef1aaedd2166485be4f.js:1
(anonymous) @ app.bundle.aef1aaedd2166485be4f.js:1
(anonymous) @ app.bundle.aef1aaedd2166485be4f.js:1
(anonymous) @ app.bundle.aef1aaedd2166485be4f.js:1
c @ vendors~app.bundle.6ca4aaacffe42287ff12.js:2
(anonymous) @ vendors~app.bundle.6ca4aaacffe42287ff12.js:2
(anonymous) @ vendors~app.bundle.6ca4aaacffe42287ff12.js:2
so @ app.bundle.aef1aaedd2166485be4f.js:1
E @ app.bundle.aef1aaedd2166485be4f.js:1
(anonymous) @ app.bundle.aef1aaedd2166485be4f.js:1
(anonymous) @ app.bundle.aef1aaedd2166485be4f.js:1
value @ app.bundle.aef1aaedd2166485be4f.js:1
xu @ vendors~app.bundle.6ca4aaacffe42287ff12.js:2
t.unstable_runWithPriority @ vendors~app.bundle.6ca4aaacffe42287ff12.js:2
ja @ vendors~app.bundle.6ca4aaacffe42287ff12.js:2
Qu @ vendors~app.bundle.6ca4aaacffe42287ff12.js:2
Su @ vendors~app.bundle.6ca4aaacffe42287ff12.js:2
(anonymous) @ vendors~app.bundle.6ca4aaacffe42287ff12.js:2
t.unstable_runWithPriority @ vendors~app.bundle.6ca4aaacffe42287ff12.js:2
ja @ vendors~app.bundle.6ca4aaacffe42287ff12.js:2
Ka @ vendors~app.bundle.6ca4aaacffe42287ff12.js:2
qa @ vendors~app.bundle.6ca4aaacffe42287ff12.js:2
se @ vendors~app.bundle.6ca4aaacffe42287ff12.js:2
En @ vendors~app.bundle.6ca4aaacffe42287ff12.js:2

Monai error log:

[MainThread] [ERROR] (uvicorn.error:412) - Exception in ASGI application
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/requests/models.py", line 974, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.10/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/uvicorn/protocols/http/h11_impl.py", line 407, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
  File "/usr/local/lib/python3.10/dist-packages/uvicorn/middleware/proxy_headers.py", line 69, in __call__
    return await self.app(scope, receive, send)
  File "/usr/local/lib/python3.10/dist-packages/fastapi/applications.py", line 1054, in __call__
    await super().__call__(scope, receive, send)
  File "/usr/local/lib/python3.10/dist-packages/starlette/applications.py", line 123, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/errors.py", line 186, in __call__
    raise exc
  File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/errors.py", line 164, in __call__
    await self.app(scope, receive, _send)
  File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/cors.py", line 85, in __call__
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/exceptions.py", line 65, in __call__
    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py", line 64, in wrapped_app
    raise exc
  File "/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    await app(scope, receive, sender)
  File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 756, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 776, in app
    await route.handle(scope, receive, send)
  File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 297, in handle
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 77, in app
    await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  File "/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py", line 64, in wrapped_app
    raise exc
  File "/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    await app(scope, receive, sender)
  File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 72, in app
    response = await func(request)
  File "/usr/local/lib/python3.10/dist-packages/fastapi/routing.py", line 278, in app
    raw_response = await run_endpoint_function(
  File "/usr/local/lib/python3.10/dist-packages/fastapi/routing.py", line 191, in run_endpoint_function
    return await dependant.call(**values)
  File "/usr/local/lib/python3.10/dist-packages/monailabel/endpoints/info.py", line 33, in api_app_info
    return app_info()
  File "/usr/local/lib/python3.10/dist-packages/monailabel/endpoints/info.py", line 28, in app_info
    return instance.info()
  File "/usr/local/lib/python3.10/dist-packages/monailabel/interfaces/app.py", line 226, in info
    "datastore": self._datastore.status(),
  File "/usr/local/lib/python3.10/dist-packages/monailabel/datastore/xnat.py", line 204, in status
    "total": len(self.list_images()),
  File "/usr/local/lib/python3.10/dist-packages/monailabel/datastore/xnat.py", line 131, in list_images
    for p in response.json().get("ResultSet", {}).get("Result", []):
  File "/usr/local/lib/python3.10/dist-packages/requests/models.py", line 978, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

To Reproduce
Setup Monai Plugin for XNAT OHIF viewer according to:
Integration-with-Xnat-Research-PACS

Expected behavior
Show Monai model selection

Environment

  • XNAT: 1.9.1.2 build 132
  • OHIF-XNAT Viewer: 3.7.1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with monailabel/datastore/xnat.py, especially list_images(), and trace how endpoints/info.py calls app_info() and the datastore status. Reproduce the XNAT integration using the linked setup and inspect the response to the projects request. Done means the OHIF viewer shows Monai model selection without the 500 or JSON decoding failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.