Viewing attachments in a conversation: `ValueError: The 'file' attribute has no file associated with it.`
Somehow an inconsistency during file uploads seems to have crept into the process:
In [1]: from grouprise.features.files.models import File
In [2]: for f in File.objects.filter(filename=None):
...: print("Invalid file:", f)
...:
Invalid file: beb3688ee46c4d93b90ae30c641a3213.asc
Invalid file: 1f12048ec01c4823811f5d8166481636.svg
Invalid file: 39bf62296aae42b49bc4d5f6193abbec.svg
Invalid file: 6fd1674512044676b0348cf06bc29b4d.svg
Invalid file: a1304b104a6045b99a6f013c7e915900.svg
Invalid file: 513152eff63f4989b00265c349af4c99.pgp
Invalid file: Themestunde_SDR_Folien-_iub5xzc._TRYBUdu.pdf
Invalid file: stefan_forster-cv73e_s2._I4xMXvQ.vcf
Invalid file: 20210919_161119-tir6vsyu._xvNm6Xc.jpg
Invalid file: Flyer_Evershagen_räumt_auf_2021-vf9hvoyc..docx
Invalid file: g_noeh-sv_xyw6j._hlPqhP4.vcf
Invalid file: snawmrmu9cz8163i.vcf
Invalid file:
Whenever someone wanted to view the related conversation in a browser, the view rendering failed with ValueError: The 'file' attribute has no file associated with it.
.
The problem seems to have occurred before and after the recent switch to the new file handling: the last file uses the new random filename schema - all other files kept the original filename.
Removing these contributions solved the rendering issue:
from grouprise.features.files.models import File
File.objects.filter(filename=None).delete()