Substra/substra-backend

Error 500 when linking dataset with datasamples

Closed this issue · 0 comments

It seems that there is first an error in the chaincode and that then this error is not properly catched in the backend, raising a new exception.

It can be reproduced using this end to end test: Substra/substra-tests#106

Traceback from server

[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend] INFO - 2020-05-06 14:20:48,103 - substrapp.ledger_utils - smartcontract invoke:updateDataSample; elaps=93.40ms; error=LedgerBadRequest
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend] ERROR - 2020-05-06 14:20:48,165 - django.request - Internal Server Error: /data_sample/bulk_update/
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend] Traceback (most recent call last):
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend]   File "/usr/src/app/substrapp/views/datasample.py", line 250, in bulk_update
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend]     data = ledger.update_datasample(args)
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend]   File "/usr/src/app/substrapp/ledger.py", line 148, in update_datasample
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend]     return _create_asset('updateDataSample', args=args)
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend]   File "/usr/src/app/substrapp/ledger.py", line 93, in _create_asset
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend]     return __create_asset(fcn, args=args, sync=True, **extra_kwargs)
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend]   File "/usr/src/app/substrapp/ledger.py", line 88, in __create_asset
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend]     return invoke_ledger(fcn=fcn, args=args, sync=sync, **extra_kwargs)
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend]   File "/usr/src/app/substrapp/ledger_utils.py", line 147, in _wrapper
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend]     return fn(*args, **kwargs)
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend]   File "/usr/src/app/substrapp/ledger_utils.py", line 326, in invoke_ledger
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend]     return _invoke_ledger(*args, **kwargs)
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend]   File "/usr/src/app/substrapp/ledger_utils.py", line 310, in _invoke_ledger
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend]     response = call_ledger('invoke', fcn=fcn, args=args, kwargs=params)
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend]   File "/usr/src/app/substrapp/ledger_utils.py", line 285, in call_ledger
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend]     return _call_ledger(call_type, fcn, *args, **kwargs)
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend]   File "/usr/src/app/substrapp/ledger_utils.py", line 275, in _call_ledger
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend]     _raise_for_status(response)
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend]   File "/usr/src/app/substrapp/ledger_utils.py", line 116, in _raise_for_status
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend]     raise exception_class.from_response_dict(response)
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend] substrapp.ledger_utils.LedgerBadRequest: problem when reading json arg: {"hashes": "6ce482fae0cf23dc654a18667b2a194ce7e7c1191e8385777d591003f98cd7fd", "dataManagerKeys": "f5df98681ebb1d4737f4707eb2ba379a49e513be33b2ae30f19c48fbdfcb7df9"}, error is: json: cannot unmarshal string into Go struct field inputUpdateDataSample.hashes of type []string
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend]
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend] During handling of the above exception, another exception occurred:
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend]
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend] Traceback (most recent call last):
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend]   File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend]     response = get_response(request)
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend]   File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py", line 115, in _get_response
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend]     response = self.process_exception_by_middleware(e, request)
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend]   File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py", line 113, in _get_response
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend]     response = wrapped_callback(request, *callback_args, **callback_kwargs)
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend]   File "/usr/local/lib/python3.6/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend]     return view_func(*args, **kwargs)
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend]   File "/usr/local/lib/python3.6/site-packages/rest_framework/viewsets.py", line 114, in view
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend]     return self.dispatch(request, *args, **kwargs)
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend]   File "/usr/local/lib/python3.6/site-packages/rest_framework/views.py", line 505, in dispatch
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend]     response = self.handle_exception(exc)
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend]   File "/usr/local/lib/python3.6/site-packages/rest_framework/views.py", line 465, in handle_exception
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend]     self.raise_uncaught_exception(exc)
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend]   File "/usr/local/lib/python3.6/site-packages/rest_framework/views.py", line 476, in raise_uncaught_exception
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend]     raise exc
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend]   File "/usr/local/lib/python3.6/site-packages/rest_framework/views.py", line 502, in dispatch
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend]     response = handler(request, *args, **kwargs)
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend]   File "/usr/src/app/substrapp/views/datasample.py", line 252, in bulk_update
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend]     return Response({'message': str(e.msg)}, status=e.st)
[backend-org-1-substra-backend-server-545687975c-v5bg2 substra-backend] AttributeError: 'LedgerBadRequest' object has no attribute 'st'

Traceback from SDK:

  File "/Users/samlesu/.virtualenvs/sb/lib/python3.7/site-packages/substra/sdk/client.py", line 787, in link_dataset_with_data_samples
    data=data,
  File "/Users/samlesu/.virtualenvs/sb/lib/python3.7/site-packages/substra/sdk/utils.py", line 170, in wrapper
    return f(*args, **kwargs)
  File "/Users/samlesu/.virtualenvs/sb/lib/python3.7/site-packages/substra/sdk/rest_client.py", line 192, in request
    **request_kwargs,
  File "/Users/samlesu/.virtualenvs/sb/lib/python3.7/site-packages/substra/sdk/rest_client.py", line 170, in _request
    return self.__request(request_name, url, **request_kwargs)
  File "/Users/samlesu/.virtualenvs/sb/lib/python3.7/site-packages/substra/sdk/rest_client.py", line 156, in __request
    raise exceptions.InternalServerError.from_request_exception(e)
substra.sdk.exceptions.InternalServerError: 500 Server Error: Internal Server Error for url: http://substra-backend.node-1.com/data_sample/bulk_update/