#30327: Failing collectstatic with ManifestFilesMixin
-------------------------------------+-------------------------------------
Reporter: Grustamli | Owner: nobody
Type: Bug | Status: new
Component: | Version: 2.2
contrib.staticfiles |
Severity: Release | Keywords: staticfiles
blocker | versioning
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Collectstatic throws `KeyError: 'ContentLength'` when used with
ManifestFileMixin. Below is the custom storage class I've written to
upload the files to Google Cloud Storage.
{{{
class CustomStorage(ManifestFilesMixin, S3Boto3Storage):
pass
}}}
in the settings.py
{{{
STATICFILES_STORAGE = 'myapp.storage.CustomStorage'
}}}
And here is the stacktrace:
{{{
UserWarning: The default behavior of S3Boto3Storage is insecure and will
change in django-storages 2.0. By default files and new buckets are saved
with an ACL of 'public-read' (globally publicly readable). Version 2.0
will default to using the bucket's ACL. To opt into the new behavior set
AWS_DEFAULT_ACL = None, otherwise to silence this warning explicitly set
AWS_DEFAULT_ACL.
"The default behavior of S3Boto3Storage is insecure and will change "
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/ufaz/webapps/ufaz_website/.venv/lib/python3.6/site-
packages/django/core/management/__init__.py", line 381, in
execute_from_command_line
utility.execute()
File "/home/ufaz/webapps/ufaz_website/.venv/lib/python3.6/site-
packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/ufaz/webapps/ufaz_website/.venv/lib/python3.6/site-
packages/django/core/management/base.py", line 316, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/ufaz/webapps/ufaz_website/.venv/lib/python3.6/site-
packages/django/core/management/base.py", line 353, in execute
output = self.handle(*args, **options)
File "/home/ufaz/webapps/ufaz_website/.venv/lib/python3.6/site-
packages/django/contrib/staticfiles/management/commands/collectstatic.py",
line 188, in handle
collected = self.collect()
File "/home/ufaz/webapps/ufaz_website/.venv/lib/python3.6/site-
packages/django/contrib/staticfiles/management/commands/collectstatic.py",
line 128, in collect
for original_path, processed_path, processed in processor:
File "/home/ufaz/webapps/ufaz_website/.venv/lib/python3.6/site-
packages/django/contrib/staticfiles/storage.py", line 402, in post_process
yield from super().post_process(*args, **kwargs)
File "/home/ufaz/webapps/ufaz_website/.venv/lib/python3.6/site-
packages/django/contrib/staticfiles/storage.py", line 236, in post_process
for name, hashed_name, processed, _ in self._post_process(paths,
adjustable_paths, hashed_files):
File "/home/ufaz/webapps/ufaz_website/.venv/lib/python3.6/site-
packages/django/contrib/staticfiles/storage.py", line 293, in
_post_process
content = pattern.sub(converter, content)
File "/home/ufaz/webapps/ufaz_website/.venv/lib/python3.6/site-
packages/django/contrib/staticfiles/storage.py", line 194, in converter
force=True, hashed_files=hashed_files,
File "/home/ufaz/webapps/ufaz_website/.venv/lib/python3.6/site-
packages/django/contrib/staticfiles/storage.py", line 131, in _url
hashed_name = hashed_name_func(*args)
File "/home/ufaz/webapps/ufaz_website/.venv/lib/python3.6/site-
packages/django/contrib/staticfiles/storage.py", line 342, in _stored_name
cache_name = self.clean_name(self.hashed_name(name))
File "/home/ufaz/webapps/ufaz_website/.venv/lib/python3.6/site-
packages/django/contrib/staticfiles/storage.py", line 99, in hashed_name
file_hash = self.file_hash(clean_name, content)
File "/home/ufaz/webapps/ufaz_website/.venv/lib/python3.6/site-
packages/django/contrib/staticfiles/storage.py", line 79, in file_hash
for chunk in content.chunks():
File "/home/ufaz/webapps/ufaz_website/.venv/lib/python3.6/site-
packages/django/core/files/base.py", line 55, in chunks
self.seek(0)
File "/home/ufaz/webapps/ufaz_website/.venv/lib/python3.6/site-
packages/django/core/files/utils.py", line 20, in <lambda>
seek = property(lambda self: self.file.seek)
File "/home/ufaz/webapps/ufaz_website/.venv/lib/python3.6/site-
packages/storages/backends/s3boto3.py", line 97, in _get_file
self.obj.download_fileobj(self._file)
File "/home/ufaz/webapps/ufaz_website/.venv/lib/python3.6/site-
packages/boto3/s3/inject.py", line 760, in object_download_fileobj
ExtraArgs=ExtraArgs, Callback=Callback, Config=Config)
File "/home/ufaz/webapps/ufaz_website/.venv/lib/python3.6/site-
packages/boto3/s3/inject.py", line 678, in download_fileobj
return future.result()
File "/home/ufaz/webapps/ufaz_website/.venv/lib/python3.6/site-
packages/s3transfer/futures.py", line 106, in result
return self._coordinator.result()
File "/home/ufaz/webapps/ufaz_website/.venv/lib/python3.6/site-
packages/s3transfer/futures.py", line 265, in result
raise self._exception
File "/home/ufaz/webapps/ufaz_website/.venv/lib/python3.6/site-
packages/s3transfer/tasks.py", line 255, in _main
self._submit(transfer_future=transfer_future, **kwargs)
File "/home/ufaz/webapps/ufaz_website/.venv/lib/python3.6/site-
packages/s3transfer/download.py", line 348, in _submit
response['ContentLength'])
KeyError: 'ContentLength'
}}}
As a reminder. I am using Google Cloud Storage since it is also S3
compatible
--
Ticket URL: <https://code.djangoproject.com/ticket/30327>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/052.336a1b70d29b9f465967def044c47e95%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.