c0c0n3 / kitt4sme.live

On a mission to bring AI to the shop floor: https://kitt4sme.eu/
MIT License
1 stars 28 forks source link

Platform Configurator Internal Server Error #292

Closed vcutrona closed 1 year ago

vcutrona commented 1 year ago

Describe the bug

I completed the AQ and then clicked the "find a kit button". The AQ then redirected me to this page PC /kits-ramp. The PC returned an Internal Server Error.

To Reproduce

Steps to reproduce the behavior:

  1. Issue a 'GET /kits-ramp request to PC with sid=a3e1a2f9-e796-4cae-a847-c055c29bea20'
  2. Alternatively, issue a GET /kits request to PC with sid=a3e1a2f9-e796-4cae-a847-c055c29bea20' (no redirection to RAMP)
  3. See error

Expected behavior

PC should retrieve the survey from AQ, then fetch tools from Digital Datasheet, then redirect the user to RAMP.

Additional context

Exceptions likes users/sessions/tools not found in DB are correctly returned to the user, as well if PC fails to access the DB. Possibly, this error may be related to a missing field in the AQ DB (user's email address), because AQ is currently not storing that info in the DB. However, I can't access the full execution log.

c0c0n3 commented 1 year ago

@vcutrona it looks like there's no software_dependencies keys in the dpes dict:

INFO:     127.0.0.6:47581 - "GET /kits-ramp?sid=a669e1e0-b241-429c-b9c9-17768bcaac23 HTTP/1.1" 500 Internal Server Error
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/uvicorn/protocols/http/h11_impl.py", line 429, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
  File "/usr/local/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 78, in __call__
    return await self.app(scope, receive, send)
  File "/usr/local/lib/python3.10/site-packages/fastapi/applications.py", line 276, in __call__
    await super().__call__(scope, receive, send)
  File "/usr/local/lib/python3.10/site-packages/starlette/applications.py", line 122, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/usr/local/lib/python3.10/site-packages/starlette/middleware/errors.py", line 184, in __call__
    raise exc
  File "/usr/local/lib/python3.10/site-packages/starlette/middleware/errors.py", line 162, in __call__
    await self.app(scope, receive, _send)
  File "/usr/local/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
    raise exc
  File "/usr/local/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
    await self.app(scope, receive, sender)
  File "/usr/local/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__
    raise e
  File "/usr/local/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 718, in __call__
    await route.handle(scope, receive, send)
  File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 276, in handle
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 66, in app
    response = await func(request)
  File "/usr/local/lib/python3.10/site-packages/fastapi/routing.py", line 237, in app
    raw_response = await run_endpoint_function(
  File "/usr/local/lib/python3.10/site-packages/fastapi/routing.py", line 165, in run_endpoint_function
    return await run_in_threadpool(dependant.call, **values)
  File "/usr/local/lib/python3.10/site-packages/starlette/concurrency.py", line 41, in run_in_threadpool
    return await anyio.to_thread.run_sync(func, *args)
  File "/usr/local/lib/python3.10/site-packages/anyio/to_thread.py", line 31, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "/usr/local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 937, in run_sync_in_worker_thread
    return await future
  File "/usr/local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 867, in run
    result = context.run(func, *args)
  File "/app/platform_configurator/main.py", line 122, in handle_kits_request_redirect
    response, user = kits(request_)
  File "/app/platform_configurator/main.py", line 80, in kits
    tools = ds_repo.get_tools()
  File "/app/platform_configurator/repositories.py", line 35, in get_tools
    dss = [datasheet_to_tool(datasheet) for datasheet in datasheets]
  File "/app/platform_configurator/repositories.py", line 35, in <listcomp>
    dss = [datasheet_to_tool(datasheet) for datasheet in datasheets]
  File "/app/platform_configurator/util/mapper.py", line 82, in datasheet_to_tool
    dependencies=[dep["module_id"] for dep in ds["software_dependencies"]])
KeyError: 'software_dependencies'
vcutrona commented 1 year ago

Thanks @c0c0n3 for posting the log. Possibly that field is missing from the datasheet. I'm going to make it optional, fix the issue and release a new PC version.

c0c0n3 commented 1 year ago

@vcutrona did #293 fix this? Can we close this issue?

vcutrona commented 1 year ago

Unfortunately, it doesn't. But I have just merged #295, which fixes this error! You can curl the URL above and get an answer:

$ curl -kl "https://kitt4sme.collab-cloud.eu/platform-configurator/kits?sid=a3e1a2f9-e796-4cae-a847-c055c29bea20"

I close this issue.