You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
NotImplementedError: This backend doesn't support absolute paths is raised when opening e-mail messages with attachments in admin interface when using some remote file storage backends (via django-storages).
I think the error is a result of trying to open attachments files directly using open() function; For example as in Message._rehydrate() method.
May be a possibe soulution could be replacing direct calls to open() with open method from django storage backends; For example using something like attachment.document.open('rb') instead of open(attachment.document.path, 'rb')
Sample error log
Internal Server Error: /admin/django_mailbox/message/<id>/change/
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/django/db/models/options.py", line 676, in get_field
return self.fields_map[field_name]
~~~~~~~~~~~~~~~^^^^^^^^^^^^
KeyError: 'envelope_headers'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/django/contrib/admin/utils.py", line 290, in lookup_field
f = _get_non_gfk_field(opts, name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/contrib/admin/utils.py", line 330, in _get_non_gfk_field
field = opts.get_field(name)
^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/db/models/options.py", line 678, in get_field
raise FieldDoesNotExist(
django.core.exceptions.FieldDoesNotExist: Message has no field named 'envelope_headers'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/core/handlers/base.py", line 220, in _get_response
response = response.render()
^^^^^^^^^^^^^^^^^
...
^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/contrib/admin/helpers.py", line 275, in contents
f, attr, value = lookup_field(field, obj, model_admin)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/contrib/admin/utils.py", line 299, in lookup_field
value = attr(obj)
^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django_mailbox/admin.py", line 76, in envelope_headers
email = msg.get_email_object()
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django_mailbox/models.py", line 798, in get_email_object
self._email_object = self._rehydrate(flat)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django_mailbox/models.py", line 699, in _rehydrate
self._rehydrate(part)
File "/usr/local/lib/python3.11/site-packages/django_mailbox/models.py", line 728, in _rehydrate
with open(attachment.document.path, 'rb') as f:
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/db/models/fields/files.py", line 65, in path
return self.storage.path(self.name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/core/files/storage/base.py", line 137, in path
raise NotImplementedError("This backend doesn't support absolute paths.")
NotImplementedError: This backend doesn't support absolute paths
The text was updated successfully, but these errors were encountered:
machakux
changed the title
Admin error when using some file storage backends
Admin error when using some of file storage backends
Oct 17, 2024
NotImplementedError: This backend doesn't support absolute paths
is raised when opening e-mail messages with attachments in admin interface when using some remote file storage backends (via django-storages).I think the error is a result of trying to open attachments files directly using
open()
function; For example as in Message._rehydrate() method.May be a possibe soulution could be replacing direct calls to
open()
with open method from django storage backends; For example using something likeattachment.document.open('rb')
instead ofopen(attachment.document.path, 'rb')
Sample error log
The text was updated successfully, but these errors were encountered: