Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FLAC files are not playable in Data Table #4716

Closed
magicznyleszek opened this issue Nov 3, 2023 · 3 comments
Closed

FLAC files are not playable in Data Table #4716

magicznyleszek opened this issue Nov 3, 2023 · 3 comments

Comments

@magicznyleszek
Copy link
Member

Description

User can upload FLAC files for the audio question type. We display a small player in the Data Table. It doesn't work.

Steps to Reproduce

Steps to break it:

  1. Use a simple form with audio question
    simple-audio-form.xlsx
  2. Add submission using flac file (e.g. https://github.com/ietf-wg-cellar/flac-test-files/blob/main/subset/01%20-%20blocksize%204096.flac)
  3. Go to Data Table and click this tiny play button. You will see 500 error on this: GET http://kf.kobo.local/api/v2/assets/aL2Nptnd37eC5BTz54TiKR/data/36/attachments/?xpath=Your_voice&format=mp3 and another error: NotSupportedError The media resource indicated by the src attribute or assigned media provider object was not suitable.

Traceback:

Traceback (most recent call last):
  File "/opt/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
psycopg2.errors.UndefinedColumn: column logger_attachment.deleted_at does not exist
LINE 1: ...media_file_size", "logger_attachment"."mimetype", "logger_at...
                                                             ^

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/venv/lib/python3.10/site-packages/django/contrib/staticfiles/handlers.py", line 76, in __call__
    return self.application(environ, start_response)
  File "/opt/venv/lib/python3.10/site-packages/django/core/handlers/wsgi.py", line 133, in __call__
    response = self.get_response(request)
  File "/opt/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 130, in get_response
    response = self._middleware_chain(request)
  File "/opt/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 49, in inner
    response = response_for_exception(request, exc)
  File "/opt/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 114, in response_for_exception
    response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
  File "/opt/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 149, in handle_uncaught_exception
    return debug.technical_500_response(request, *exc_info)
  File "/opt/venv/lib/python3.10/site-packages/django_extensions/management/technical_response.py", line 40, in null_technical_500_response
    raise exc_value.with_traceback(tb)
  File "/opt/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/opt/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/opt/venv/lib/python3.10/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "/opt/venv/lib/python3.10/site-packages/rest_framework/viewsets.py", line 125, in view
    return self.dispatch(request, *args, **kwargs)
  File "/opt/venv/lib/python3.10/site-packages/rest_framework/views.py", line 509, in dispatch
    response = self.handle_exception(exc)
  File "/opt/venv/lib/python3.10/site-packages/rest_framework/views.py", line 469, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/opt/venv/lib/python3.10/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
    raise exc
  File "/opt/venv/lib/python3.10/site-packages/rest_framework/views.py", line 506, in dispatch
    response = handler(request, *args, **kwargs)
  File "/srv/src/kpi/kpi/views/v2/attachment.py", line 76, in list
    return self._get_response(request, submission_id_or_uuid, xpath=xpath)
  File "/srv/src/kpi/kpi/views/v2/attachment.py", line 87, in _get_response
    attachment = self.asset.deployment.get_attachment(
  File "/srv/src/kpi/kpi/deployment_backends/kobocat_backend.py", line 707, in get_attachment
    attachment = ReadOnlyKobocatAttachment.objects.get(**filters)
  File "/opt/venv/lib/python3.10/site-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/opt/venv/lib/python3.10/site-packages/django/db/models/query.py", line 431, in get
    num = len(clone)
  File "/opt/venv/lib/python3.10/site-packages/django/db/models/query.py", line 262, in __len__
    self._fetch_all()
  File "/opt/venv/lib/python3.10/site-packages/django/db/models/query.py", line 1324, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
  File "/opt/venv/lib/python3.10/site-packages/django/db/models/query.py", line 51, in __iter__
    results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
  File "/opt/venv/lib/python3.10/site-packages/django/db/models/sql/compiler.py", line 1175, in execute_sql
    cursor.execute(sql, params)
  File "/opt/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 98, in execute
    return super().execute(sql, params)
  File "/opt/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 66, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/opt/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/opt/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 79, in _execute
    with self.db.wrap_database_errors:
  File "/opt/venv/lib/python3.10/site-packages/django/db/utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/opt/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: column logger_attachment.deleted_at does not exist
LINE 1: ...media_file_size", "logger_attachment"."mimetype", "logger_at...
                                                             ^

Expected behavior

It should just work

Additional details

The #4676 PR is fixing the code to use proper endpoint here. Please either wait for it to be merged or start working from it.

@jnm
Copy link
Member

jnm commented Nov 8, 2023

Looks like a database migration problem? Internal discussion: https://chat.kobotoolbox.org/#narrow/stream/4-Kobo-Dev/topic/Supported.20File.20Types/near/296810

@jnm
Copy link
Member

jnm commented Nov 8, 2023

I just tested this on production and it works 🤔 Did you do that as well? 😛

If there's a persistent database migration bug on one of the branches, then let's update the description to explain that.

My guess is that whatever instance was giving you ProgrammingError: column logger_attachment.deleted_at does not exist would actually not accept any submission attachments at all.

With any luck, the problem is that your KoboCAT is too old for the version of KPI you are running 🤞

@magicznyleszek
Copy link
Member Author

After starting my local env from scratch the problem is gone :)

@magicznyleszek magicznyleszek closed this as not planned Won't fix, can't repro, duplicate, stale Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants