Databases with userfiles uploaded prior to a bug fix are not possible to snapshot, duplicate etc.
Describe the problem
Prior to 1.12.0 an error occurred when you tried to upload a file to database using an url which had a querystring. https://gitlab.com/bramw/baserow/-/merge_requests/958 fixed this issue. However if userfiles were uploaded prior to this fix they will render a database/table/field that contains them to be unable to be duplicated or snapshotted.
InvalidUserFileNameError: The provided name is not in the correct format.
File "baserow/core/jobs/tasks.py", line 74, in run_async_job
raise e
File "baserow/core/jobs/tasks.py", line 37, in run_async_job
JobHandler().run(job)
File "baserow/core/jobs/handler.py", line 66, in run
return job_type.run(job, progress)
File "baserow/core/snapshots/job_type.py", line 39, in run
SnapshotHandler().perform_create(job.snapshot, progress)
File "baserow/core/snapshots/handler.py", line 348, in perform_create
application, None, default_storage
File "baserow/contrib/database/application_types.py", line 139, in export_serialized
serialized_tables = self.export_tables_serialized(tables, files_zip, storage)
File "baserow/contrib/database/application_types.py", line 105, in export_tables_serialized
row, field_name, table_cache, files_zip, storage
File "baserow/contrib/database/fields/field_types.py", line 1946, in get_export_serialized_value
user_file = UserFile.objects.all().name(file["name"]).get()
File "baserow/core/user_files/managers.py", line 13, in name
q_or |= Q(**self.model.deconstruct_name(name))
File "baserow/core/user_files/models.py", line 72, in deconstruct_name
name, "The provided name is not in the correct format."
The file name causing this crash (anonymized) is 'ANON_ANON.jpeg?w=500'
The fix
We need to add a database migration which will find and fix these invalid UserFiles in the database. Additionally we should look at the get_export_serialized_value
and decide what should happen if this InvalidUserFileNameError
is raised, is it correct to crash everything?