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

File not found error on Azure #1439

Closed
Morefra opened this issue Jul 25, 2024 · 4 comments
Closed

File not found error on Azure #1439

Morefra opened this issue Jul 25, 2024 · 4 comments

Comments

@Morefra
Copy link

Morefra commented Jul 25, 2024

After updating django-storages to 1.14, when trying to upload an image through the admin panel I'm getting a file not found error with the following trace:

Internal Server Error: /admin/images/multiple/add/
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/sentry_sdk/integrations/django/views.py", line 90, in sentry_wrapped_callback
    return callback(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/views/decorators/cache.py", line 80, in _view_wrapper
    response = view_func(request, *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/wagtail/admin/urls/__init__.py", line 178, in wrapper
    return view_func(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/wagtail/admin/auth.py", line 151, in decorated_view
    response = view_func(request, *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/views/generic/base.py", line 104, in view
    return self.dispatch(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/utils/decorators.py", line 48, in _wrapper
      return bound_method(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/views/decorators/vary.py", line 31, in _view_wrapper
    response = func(request, *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/wagtail/admin/views/generic/multiple_upload.py", line 45, in dispatch
    return super().dispatch(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/wagtail/admin/views/generic/permissions.py", line 31, in dispatch
    return super().dispatch(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/views/generic/base.py", line 143, in dispatch
    return handler(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/wagtail/admin/views/generic/multiple_upload.py", line 147, in post
    self.object = self.save_object(form)
                  ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/wagtail/images/views/multiple.py", line 81, in save_object
    image.save()
  File "/wagtail/common/models.py", line 779, in save
    super().save(*args, **kwargs)
  File "/usr/local/lib/python3.12/site-packages/django/db/models/base.py", line 822, in save
    self.save_base(
  File "/usr/local/lib/python3.12/site-packages/django/db/models/base.py", line 909, in save_base
    updated = self._save_table(
              ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/db/models/base.py", line 1071, in _save_table
    results = self._do_insert(
              ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/db/models/base.py", line 1112, in _do_insert
    return manager._insert(
           ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/db/models/manager.py", line 87, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/db/models/query.py", line 1847, in _insert
    return query.get_compiler(using=using).execute_sql(returning_fields)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/db/models/sql/compiler.py", line 1822, in execute_sql
    for sql, params in self.as_sql():
                       ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/db/models/sql/compiler.py", line 1747, in as_sql
    self.prepare_value(field, self.pre_save_val(field, obj))
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/db/models/sql/compiler.py", line 1695, in pre_save_val
    return field.pre_save(obj, add=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/db/models/fields/files.py", line 317, in pre_save
    file.save(file.name, file.file, save=False)
  File "/usr/local/lib/python3.12/site-packages/django/db/models/fields/files.py", line 94, in save
    setattr(self.instance, self.field.attname, self.name)
  File "/usr/local/lib/python3.12/site-packages/django/db/models/fields/files.py", line 379, in __set__
    self.field.update_dimension_fields(instance, force=True)
  File "/usr/local/lib/python3.12/site-packages/django/db/models/fields/files.py", line 492, in update_dimension_fields
    width = file.width
            ^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/core/files/images.py", line 21, in width
    return self._get_image_dimensions()[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/wagtail/images/models.py", line 225, in _get_image_dimensions
    self._dimensions_cache = self.get_image_dimensions()
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/wagtail/images/models.py", line 235, in get_image_dimensions
    self.open()
  File "/usr/local/lib/python3.12/site-packages/django/db/models/fields/files.py", line 79, in open
    self.file = self.storage.open(self.name, mode)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/core/files/storage/base.py", line 22, in open
    return self._open(name, mode)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django_storage_url/backends/az.py", line 76, in _open
    return AzureStorageFile(name, mode, self)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django_storage_url/backends/az.py", line 14, in __init__
    raise IOError("File does not exist: %s" % name)
OSError: File does not exist: original_images/test_image.jpg

Checking on azure I see that the file was uploaded successfully, but for some reason wagtail (django) was not able to retrieve it.
This looks very similar to issue #802 from 2019, but I don't see a solution for it.

versions used:
Wagtail 6.1.3 (Django 5.0.7)
django-storages 1.14.1
azure-core: 1.30.2
azure-storage-blob: 12.21.0

@fscherf
Copy link

fscherf commented Aug 28, 2024

@Morefra: What is the last version of django-storages that works for you? Are you using django-storages-url, and if so, which version?

@Morefra
Copy link
Author

Morefra commented Aug 28, 2024

@fscherf here our setup as of this monday. We tried to update to django-storages 1.14.4 and it broke again

Wagtail 6.2.1 (Django 5.1)
django-storages 1.14.3
django-storage-url 0.12.0
azure-core 1.30.2
azure-storage-blob 12.22.0

@fscherf
Copy link

fscherf commented Aug 29, 2024

@Morefra We released django-storage-url 0.12.1. Can you please if it fixes your issue?

@jschneier
Copy link
Owner

Likely a dupe of #1430, apologies, have not had a time to figure out a real solution.

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

3 participants