cvat-ai / cvat

Annotate better with CVAT, the industry-leading data engine for machine learning. Used and trusted by teams at any scale, for data of any scale.
https://cvat.ai
MIT License
12.48k stars 2.99k forks source link

Accessing the API through a container on the same network as CVAT does not Propagate HTTP_ORIGIN #4894

Open KhanMechAI opened 2 years ago

KhanMechAI commented 2 years ago

My actions before raising this issue

Manually solved issue by setting 'Origin' header

Expected Behaviour

HTTP_ORIGIN request header to contain the 'cvat' network adders or IP when using Tus Upload

Current Behaviour

"HTTP_ORIGIN" is not found in request META

Possible Solution

Unsure without diving deeper into the implementation

Steps to Reproduce (for bugs)

  1. Start CVAT
  2. Create another containered service to hit the CVAT API. Container must have access to and be on the CVAT network.
  3. Mimic a Tus upload
  4. Error

Context

Trying to upload videos programmatically through the API from a service in a docker container with access to the cvat network.

Your Environment

2022-09-01 09:08:16,913 DEBG 'runserver' stderr output: [Thu Sep 01 09:08:16.913696 2022] [wsgi:error] [pid 17709:tid 140400104261376] [remote 192.168.112.8:48378] [2022-09-01 09:08:16,913] ERROR django.request: Internal Server Error: /api/tasks/62/data/ [Thu Sep 01 09:08:16.913715 2022] [wsgi:error] [pid 17709:tid 140400104261376] [remote 192.168.112.8:48378] Traceback (most recent call last): [Thu Sep 01 09:08:16.913718 2022] [wsgi:error] [pid 17709:tid 140400104261376] [remote 192.168.112.8:48378] File "/opt/venv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner [Thu Sep 01 09:08:16.913720 2022] [wsgi:error] [pid 17709:tid 140400104261376] [remote 192.168.112.8:48378] response = get_response(request) [Thu Sep 01 09:08:16.913722 2022] [wsgi:error] [pid 17709:tid 140400104261376] [remote 192.168.112.8:48378] File "/opt/venv/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response [Thu Sep 01 09:08:16.913724 2022] [wsgi:error] [pid 17709:tid 140400104261376] [remote 192.168.112.8:48378] response = wrapped_callback(request, *callback_args, callback_kwargs) [Thu Sep 01 09:08:16.913726 2022] [wsgi:error] [pid 17709:tid 140400104261376] [remote 192.168.112.8:48378] File "/opt/venv/lib/python3.8/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view [Thu Sep 01 09:08:16.913727 2022] [wsgi:error] [pid 17709:tid 140400104261376] [remote 192.168.112.8:48378] return view_func(*args, *kwargs) [Thu Sep 01 09:08:16.913729 2022] [wsgi:error] [pid 17709:tid 140400104261376] [remote 192.168.112.8:48378] File "/opt/venv/lib/python3.8/site-packages/rest_framework/viewsets.py", line 125, in view [Thu Sep 01 09:08:16.913731 2022] [wsgi:error] [pid 17709:tid 140400104261376] [remote 192.168.112.8:48378] return self.dispatch(request, args, kwargs) [Thu Sep 01 09:08:16.913732 2022] [wsgi:error] [pid 17709:tid 140400104261376] [remote 192.168.112.8:48378] File "/opt/venv/lib/python3.8/site-packages/rest_framework/views.py", line 509, in dispatch [Thu Sep 01 09:08:16.913734 2022] [wsgi:error] [pid 17709:tid 140400104261376] [remote 192.168.112.8:48378] response = self.handle_exception(exc) [Thu Sep 01 09:08:16.913736 2022] [wsgi:error] [pid 17709:tid 140400104261376] [remote 192.168.112.8:48378] File "/opt/venv/lib/python3.8/site-packages/rest_framework/views.py", line 469, in handle_exception [Thu Sep 01 09:08:16.913737 2022] [wsgi:error] [pid 17709:tid 140400104261376] [remote 192.168.112.8:48378] self.raise_uncaught_exception(exc) [Thu Sep 01 09:08:16.913739 2022] [wsgi:error] [pid 17709:tid 140400104261376] [remote 192.168.112.8:48378] File "/opt/venv/lib/python3.8/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception [Thu Sep 01 09:08:16.913741 2022] [wsgi:error] [pid 17709:tid 140400104261376] [remote 192.168.112.8:48378] raise exc [Thu Sep 01 09:08:16.913742 2022] [wsgi:error] [pid 17709:tid 140400104261376] [remote 192.168.112.8:48378] File "/opt/venv/lib/python3.8/site-packages/rest_framework/views.py", line 506, in dispatch [Thu Sep 01 09:08:16.913744 2022] [wsgi:error] [pid 17709:tid 140400104261376] [remote 192.168.112.8:48378] response = handler(request, *args, **kwargs) [Thu Sep 01 09:08:16.913746 2022] [wsgi:error] [pid 17709:tid 140400104261376] [remote 192.168.112.8:48378] File "/home/django/cvat/apps/engine/views.py", line 768, in data [Thu Sep 01 09:08:16.913748 2022] [wsgi:error] [pid 17709:tid 140400104261376] [remote 192.168.112.8:48378] return self.upload_data(request) [Thu Sep 01 09:08:16.913749 2022] [wsgi:error] [pid 17709:tid 140400104261376] [remote 192.168.112.8:48378] File "/home/django/cvat/apps/engine/mixins.py", line 140, in upload_data [Thu Sep 01 09:08:16.913751 2022] [wsgi:error] [pid 17709:tid 140400104261376] [remote 192.168.112.8:48378] return self.init_tus_upload(request) [Thu Sep 01 09:08:16.913752 2022] [wsgi:error] [pid 17709:tid 140400104261376] [remote 192.168.112.8:48378] File "/home/django/cvat/apps/engine/mixins.py", line 175, in init_tus_upload [Thu Sep 01 09:08:16.913754 2022] [wsgi:error] [pid 17709:tid 140400104261376] [remote 192.168.112.8:48378] location = request.META.get('HTTP_ORIGIN') + request.META.get('PATH_INFO') [Thu Sep 01 09:08:16.913758 2022] [wsgi:error] [pid 17709:tid 140400104261376] [remote 192.168.112.8:48378] TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

KhanMechAI commented 2 years ago

?