In some cases, the agency responds with multiple attachments in an email response named the same thing (i.e. AttachedImage). This causes an error when the user tries to download them - as the platform gets confused as to which attachment the user is requesting.
Describe the bug
In some cases, the agency responds with multiple attachments in an email response named the same thing (i.e.
AttachedImage
). This causes an error when the user tries to download them - as the platform gets confused as to which attachment the user is requesting.Error Summary
``` From: "UIPA.org Administrators" <[info@foi.uipa.org](mailto:info@foi.uipa.org)> Subject: [Froide] ERROR (EXTERNAL IP): Internal Server Error: /files/foi/4050/AttachedImage Date: March 5, 2024 at 11:07:12 AM HST To: [admin@uipa.org](mailto:admin@uipa.org), [ryan@codeforhawaii.org](mailto:ryan@codeforhawaii.org) Reply-To: [info@uipa.org](mailto:info@uipa.org) Internal Server Error: /files/foi/4050/AttachedImage MultipleObjectsReturned at /files/foi/4050/AttachedImage get() returned more than one FoiAttachment -- it returned 5! Request Method: GET Request URL: [https://uipa.org/files/foi/4050/AttachedImage](https://urldefense.com/v3/__https://uipa.org/files/foi/4050/AttachedImage__;!!PvDODwlR4mBZyAb0!Wue2czg32XxfDieDKL5HOvTYIO4s_EmFHvvb2nM4h68yzQ69hBW2slztdPMPoVBgOY5r3fSD_MxcXQ$) Django Version: 1.10.2 Python Executable: /usr/local/bin/uwsgi Python Version: 2.7.6 Python Path: ['.', '', '/var/www/applications/uipa_org/venvs/releases/20171206105506Z/src/django-overextends', '/var/www/applications/uipa_org/venvs/releases/20171206105506Z/src/froide', '/var/www/applications/uipa_org/venvs/current/lib/python2.7', '/var/www/applications/uipa_org/venvs/current/lib/python2.7/plat-x86_64-linux-gnu', '/var/www/applications/uipa_org/venvs/current/lib/python2.7/lib-tk', '/var/www/applications/uipa_org/venvs/current/lib/python2.7/lib-old', '/var/www/applications/uipa_org/venvs/current/lib/python2.7/lib-dynload', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/var/www/applications/uipa_org/venvs/current/local/lib/python2.7/site-packages', '/var/www/applications/uipa_org/app/releases/20171206105506Z', '/var/www/applications/uipa_org/venvs/releases/20171206105506Z/src/froide', '/var/www/applications/uipa_org/venvs/releases/20171206105506Z/src/froide/..'] Server time: Tue, 5 Mar 2024 11:07:09 -1000 Installed Applications: ['django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.admin', 'django_comments', 'django.contrib.flatpages', 'django.contrib.sitemaps', 'haystack', 'taggit', 'floppyforms', 'overextends', 'tastypie', 'storages', 'compressor', 'froide.foirequest', 'froide.foirequestfollower', 'froide.frontpage', 'froide.publicbody', 'froide.account', 'froide.redaction', 'froide.foisite', 'froide.helper', 'uipa_org.theme', 'celery_haystack', 'djcelery_email', 'django.contrib.redirects', 'uipa_org.uipa_constants', 'uipa_org.theme.templatetags.uipa_extras', 'tinymce', 'raven.contrib.django.raven_compat'] Installed Middleware: [u'raven.contrib.django.middleware.SentryMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.common.CommonMiddleware', 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware', 'django.contrib.redirects.middleware.RedirectFallbackMiddleware', 'froide.account.middleware.AcceptNewTermsMiddleware'] Traceback: File "/var/www/applications/uipa_org/venvs/current/local/lib/python2.7/site-packages/django/core/handlers/exception.py" in inner 39. response = get_response(request) File "/var/www/applications/uipa_org/venvs/current/local/lib/python2.7/site-packages/django/core/handlers/base.py" in _legacy_get_response 249. response = self._get_response(request) File "/var/www/applications/uipa_org/venvs/current/local/lib/python2.7/site-packages/django/core/handlers/base.py" in _get_response 187. response = self.process_exception_by_middleware(e, request) File "/var/www/applications/uipa_org/venvs/current/local/lib/python2.7/site-packages/django/core/handlers/base.py" in _get_response 185. response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/var/www/applications/uipa_org/venvs/releases/20171206105506Z/src/froide/froide/foirequest/views.py" in auth_message_attachment 890. name=attachment_name) File "/var/www/applications/uipa_org/venvs/current/local/lib/python2.7/site-packages/django/shortcuts.py" in get_object_or_404 85. return queryset.get(*args, **kwargs) File "/var/www/applications/uipa_org/venvs/current/local/lib/python2.7/site-packages/django/db/models/query.py" in get 389. (self.model._meta.object_name, num) Exception Type: MultipleObjectsReturned at /files/foi/4050/AttachedImage Exception Value: get() returned more than one FoiAttachment -- it returned 5! Request information: USER: s.steiner GET: No GET data POST: No POST data FILES: No FILES data COOKIES: sessionid = 'f4j6ma6wl9pfit5m3u3qjt3u0fzcov6i' _ga = 'GA1.2.287914878.1696440220' _gid = 'GA1.2.8195141.1709671900' _gat = '1' META: CONTENT_LENGTH = '' CONTENT_TYPE = '' DOCUMENT_ROOT = '/var/www/applications/uipa_org/app/current' HTTPS = 'on' HTTP_ACCEPT = 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8' HTTP_ACCEPT_ENCODING = 'gzip, deflate, br' HTTP_ACCEPT_LANGUAGE = 'en-US,en;q=0.5' HTTP_CONNECTION = 'keep-alive' HTTP_COOKIE = '_ga=GA1.2.287914878.1696440220; sessionid=f4j6ma6wl9pfit5m3u3qjt3u0fzcov6i; _gid=GA1.2.8195141.1709671900; _gat=1' HTTP_DNT = '1' HTTP_HOST = '[uipa.org](http://uipa.org/)' HTTP_REFERER = '[https://uipa.org/request/production-and-injection-reports-puna-geothermal-venture-2/](https://urldefense.com/v3/__https://uipa.org/request/production-and-injection-reports-puna-geothermal-venture-2/__;!!PvDODwlR4mBZyAb0!Wue2czg32XxfDieDKL5HOvTYIO4s_EmFHvvb2nM4h68yzQ69hBW2slztdPMPoVBgOY5r3fQOTrv3RA$)' HTTP_SEC_FETCH_DEST = 'document' HTTP_SEC_FETCH_MODE = 'navigate' HTTP_SEC_FETCH_SITE = 'same-origin' HTTP_SEC_FETCH_USER = '?1' HTTP_UPGRADE_INSECURE_REQUESTS = '1' HTTP_USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:123.0) Gecko/20100101 Firefox/123.0' Host = '[uipa.org](http://uipa.org/)' PATH_INFO = u'/files/foi/4050/AttachedImage' QUERY_STRING = '' REMOTE_ADDR = '147.81.46.99' REMOTE_PORT = '62190' REQUEST_METHOD = 'GET' REQUEST_SCHEME = 'https' REQUEST_URI = '/files/foi/4050/AttachedImage' SCRIPT_NAME = u'' SERVER_NAME = '[uipa.org](http://uipa.org/)' SERVER_PORT = '443' SERVER_PROTOCOL = 'HTTP/1.1' X-Forwarded-For = '147.81.46.99' X-Forwarded-Proto = '' X-Real-IP = '147.81.46.99' uwsgi.core = 23 uwsgi.node = 'CBLAW' uwsgi.version = '2.0.11.1' wsgi.errors =Expected behavior User is able to download multiple attachments, even if they are named the same thing.