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

Getting "The file could not be found" when using S3ManifestStaticStorage #1440

Closed
dalpii opened this issue Aug 6, 2024 · 4 comments
Closed

Comments

@dalpii
Copy link

dalpii commented Aug 6, 2024

Hello guys, I hope someone can help me. I've implemented the default storages.backends.s3.S3Storage for uploads and static files, and it went just fine.

Now I'm trying to setup static files to use storages.backends.s3.S3ManifestStaticStorage and I'm getting an error when running with DEBUG = False, on production:

ValueError: The file 'admin/css/widgets.css' could not be found with <storages.backends.s3.S3ManifestStaticStorage object at 0x750f4d2ba750>.

As you can see, it doesn't seem to be able to find a CSS file from Django admin, but checking my bucket, the file is there:

Captura de Tela 2024-08-06 às 17 41 16

And my bucket policy, which was working just fine with S3Storage:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::bucket-name/*"
        }
    ]
}

I've tried some approaches/tests with no success, maybe it's some race condition?

Thanks!

@dalpii
Copy link
Author

dalpii commented Aug 6, 2024

Maybe not a race condition because running the command again, without deleting any file from S3, gives the same error.

All files are inside admin/css/:

Captura de Tela 2024-08-06 às 17 49 52

@lchojnacki
Copy link

lchojnacki commented Aug 14, 2024

I encountered very similar problem in my project (ValueError: The file 'admin/img/sorting-icons.svg' could not be found with <my.custom.storage.Class(S3ManifestStaticStorage)>.). Downgrading django-storages to version 1.14.2 helped.

@temi4
Copy link

temi4 commented Aug 19, 2024

Hello.

Problem after the update, because the logic of the self.file_overwrite parameter in the function "exists" has changed

if self.file_overwrite:

def exists(self, name):
if self.file_overwrite: <!-- add this
return False

And this function is used in HashedFilesMixin
https://github.com/django/django/blob/a57596e443ecb67140e1a9fc0f0e87446b2d0174/django/contrib/staticfiles/storage.py#L142

I used file_overwrite for my static files. Perhaps this shouldn't be done?

@dalpii
Copy link
Author

dalpii commented Aug 22, 2024

I'm closing this issue because this error is caused by #1430.
As @lchojnacki and @temi4 pointed out, downgrading or changing the exists function on storage works for now.

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