maxSIMhealth / GEN

Gamified Educational Network
GNU Affero General Public License v3.0
4 stars 3 forks source link

[Assets] SRI package is conflicting with Django-storages #502

Closed andreibosco closed 1 year ago

andreibosco commented 1 year ago

Looks like SRI is now failing to get the path of static assets served using Django-storages

andreibosco commented 1 year ago

Log:

[gen] [2023-06-19 16:18:51] 2023-06-19 16:18:51,662 ERROR [django.request:241] log 2 140491262475064 Internal Server Error: /courses/1/
[gen] [2023-06-19 16:18:51] Traceback (most recent call last):
[gen] [2023-06-19 16:18:51]   File "/env/lib/python3.10/site-packages/asgiref/sync.py", line 534, in thread_handler
[gen] [2023-06-19 16:18:51]     raise exc_info[1]
[gen] [2023-06-19 16:18:51]   File "/env/lib/python3.10/site-packages/django/core/handlers/exception.py", line 42, in inner
[gen] [2023-06-19 16:18:51]     response = await get_response(request)
[gen] [2023-06-19 16:18:51]   File "/env/lib/python3.10/site-packages/django/core/handlers/base.py", line 253, in _get_response_async
[gen] [2023-06-19 16:18:51]     response = await wrapped_callback(
[gen] [2023-06-19 16:18:51]   File "/env/lib/python3.10/site-packages/asgiref/sync.py", line 479, in __call__
[gen] [2023-06-19 16:18:51]     ret: _R = await loop.run_in_executor(
[gen] [2023-06-19 16:18:51]   File "/env/lib/python3.10/site-packages/asgiref/current_thread_executor.py", line 40, in run
[gen] [2023-06-19 16:18:51]     result = self.fn(*self.args, **self.kwargs)
[gen] [2023-06-19 16:18:51]   File "/env/lib/python3.10/site-packages/asgiref/sync.py", line 538, in thread_handler
[gen] [2023-06-19 16:18:51]     return func(*args, **kwargs)
[gen] [2023-06-19 16:18:51]   File "/env/lib/python3.10/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapper_view
[gen] [2023-06-19 16:18:51]     return view_func(request, *args, **kwargs)
[gen] [2023-06-19 16:18:51]   File "/gen/app/GEN/decorators.py", line 26, in _wrapped_view
[gen] [2023-06-19 16:18:51]     return view_func(request, *args, **kwargs)
[gen] [2023-06-19 16:18:51]   File "/gen/app/GEN/decorators.py", line 90, in _wrapped_view
[gen] [2023-06-19 16:18:51]     return view_func(request, *args, **kwargs)
[gen] [2023-06-19 16:18:51]   File "/gen/app/courses/views.py", line 98, in course
[gen] [2023-06-19 16:18:51]     return render(
[gen] [2023-06-19 16:18:51]   File "/env/lib/python3.10/site-packages/django/shortcuts.py", line 24, in render
[gen] [2023-06-19 16:18:51]     content = loader.render_to_string(template_name, context, request, using=using)
[gen] [2023-06-19 16:18:51]   File "/env/lib/python3.10/site-packages/django/template/loader.py", line 62, in render_to_string
[gen] [2023-06-19 16:18:51]     return template.render(context, request)
[gen] [2023-06-19 16:18:51]   File "/env/lib/python3.10/site-packages/django/template/backends/django.py", line 61, in render
[gen] [2023-06-19 16:18:51]     return self.template.render(context)
[gen] [2023-06-19 16:18:51]   File "/env/lib/python3.10/site-packages/django/template/base.py", line 175, in render
[gen] [2023-06-19 16:18:51]     return self._render(context)
[gen] [2023-06-19 16:18:51]   File "/env/lib/python3.10/site-packages/django/test/utils.py", line 112, in instrumented_test_render
[gen] [2023-06-19 16:18:51]     return self.nodelist.render(context)
[gen] [2023-06-19 16:18:51]   File "/env/lib/python3.10/site-packages/django/template/base.py", line 1005, in render
[gen] [2023-06-19 16:18:51]     return SafeString("".join([node.render_annotated(context) for node in self]))
[gen] [2023-06-19 16:18:51]   File "/env/lib/python3.10/site-packages/django/template/base.py", line 1005, in <listcomp>
[gen] [2023-06-19 16:18:51]     return SafeString("".join([node.render_annotated(context) for node in self]))
[gen] [2023-06-19 16:18:51]   File "/env/lib/python3.10/site-packages/django/template/base.py", line 966, in render_annotated
[gen] [2023-06-19 16:18:51]     return self.render(context)
[gen] [2023-06-19 16:18:51]   File "/env/lib/python3.10/site-packages/django/template/loader_tags.py", line 157, in render
[gen] [2023-06-19 16:18:51]     return compiled_parent._render(context)
[gen] [2023-06-19 16:18:51]   File "/env/lib/python3.10/site-packages/django/test/utils.py", line 112, in instrumented_test_render
[gen] [2023-06-19 16:18:51]     return self.nodelist.render(context)
[gen] [2023-06-19 16:18:51]   File "/env/lib/python3.10/site-packages/django/template/base.py", line 1005, in render
[gen] [2023-06-19 16:18:51]     return SafeString("".join([node.render_annotated(context) for node in self]))
[gen] [2023-06-19 16:18:51]   File "/env/lib/python3.10/site-packages/django/template/base.py", line 1005, in <listcomp>
[gen] [2023-06-19 16:18:51]     return SafeString("".join([node.render_annotated(context) for node in self]))
[gen] [2023-06-19 16:18:51]   File "/env/lib/python3.10/site-p
[gen] [2023-06-19 16:18:51]   File "/env/lib/python3.10/site-packages/django/template/loader_tags.py", line 157, in render
[gen] [2023-06-19 16:18:51]     return compiled_parent._render(context)
[gen] [2023-06-19 16:18:51]   File "/env/lib/python3.10/site-packages/django/test/utils.py", line 112, in instrumented_test_render
[gen] [2023-06-19 16:18:51]     return self.nodelist.render(context)
[gen] [2023-06-19 16:18:51]   File "/env/lib/python3.10/site-packages/django/template/base.py", line 1005, in render
[gen] [2023-06-19 16:18:51]     return SafeString("".join([node.render_annotated(context) for node in self]))
[gen] [2023-06-19 16:18:51]   File "/env/lib/python3.10/site-packages/django/template/base.py", line 1005, in <listcomp>
[gen] [2023-06-19 16:18:51]     return SafeString("".join([node.render_annotated(context) for node in self]))
[gen] [2023-06-19 16:18:51]   File "/env/lib/python3.10/site-packages/django/template/base.py", line 966, in render_annotated
[gen] [2023-06-19 16:18:51]     return self.render(context)
[gen] [2023-06-19 16:18:51]   File "/env/lib/python3.10/site-packages/django/template/library.py", line 237, in render
[gen] [2023-06-19 16:18:51]     output = self.func(*resolved_args, **resolved_kwargs)
[gen] [2023-06-19 16:18:51]   File "/env/lib/python3.10/site-packages/sri/templatetags/sri.py", line 73, in sri_static
[gen] [2023-06-19 16:18:51]     extra_tag_attrs["integrity"] = sri_integrity_static(path, algorithm)
[gen] [2023-06-19 16:18:51]   File "/env/lib/python3.10/site-packages/sri/templatetags/sri.py", line 80, in sri_integrity_static
[gen] [2023-06-19 16:18:51]     return calculate_integrity_of_static(path, algorithm_type)
[gen] [2023-06-19 16:18:51]   File "/env/lib/python3.10/site-packages/sri/integrity.py", line 15, in calculate_integrity_of_static
[gen] [2023-06-19 16:18:51]     return calculate_integrity(get_static_path(static_path), algorithm)
[gen] [2023-06-19 16:18:51]   File "/env/lib/python3.10/site-packages/sri/utils.py", line 21, in get_static_path
[gen] [2023-06-19 16:18:51]     collected_file_path = staticfiles_storage.path(path)
[gen] [2023-06-19 16:18:51]   File "/env/lib/python3.10/site-packages/django/core/files/storage/base.py", line 121, in path
[gen] [2023-06-19 16:18:51]     raise NotImplementedError("This backend doesn't support absolute paths.")
[gen] [2023-06-19 16:18:51] NotImplementedError: This backend doesn't support absolute paths.
andreibosco commented 1 year ago

Reverting to using Django's native static templatetag instead of sri_static until I find out what is causing this.