Opened 17 months ago

Closed 17 months ago

Last modified 16 months ago

#34679 closed Bug (needsinfo)

Cannot run collectstatic with existing unsupported manifest file

Reported by: Jarosław Wygoda Owned by: Jarosław Wygoda
Component: contrib.staticfiles Version: 4.1
Severity: Normal Keywords:
Cc: Jarosław Wygoda Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I tried to run collectstatic with ManifestStaticFilesStorage on django 4.1 with existing staticfiles generated by django 4.2. Django 4.2 introduced manifest version 1.1 which is not supported by Django 4.1. I've found out that I can't run collectstatic when unsupported manifest already exists.

Change History (9)

comment:1 by Jarosław Wygoda, 17 months ago

Owner: changed from nobody to Jarosław Wygoda
Status: newassigned

comment:2 by Natalia Bidart, 17 months ago

Resolution: needsinfo
Status: assignedclosed

Hello!

I'll be closing this ticket as needsinfo since there is no traceback nor a reproducer was provided, but please re-open if you have more concrete information (traceback, detailed steps to reproduce the bug, sample project to exercise this issue, etc.).

You can also seek more help in the user forum. The best place to get answers to your issue is using any of the user support channels from this link.

Thank you!

comment:3 by Jarosław Wygoda, 17 months ago

Cc: Jarosław Wygoda added
Resolution: needsinfo
Status: closednew

Hi Natalia,

I've already figured out this issue. Please take a look at my pr: https://github.com/django/django/pull/17015/files
You can reproduce it either by reverting my changes in django/contrib/staticfiles/storage.py and running TestManifestStaticFilesStorageRollback or by running ./manage.py collectstatic with ManifestStaticFilesStorage on Django 4.2 and then on Django 4.1.

Please find the traceback below.

Traceback (most recent call last):
  File "/tests/django/tests/staticfiles_tests/test_storage.py", line 912, in test_collectstatic_with_unsupported_version
    self.run_collectstatic()
  File "/tests/django/tests/staticfiles_tests/cases.py", line 89, in run_collectstatic
    call_command(
  File "/tests/django/django/core/management/__init__.py", line 194, in call_command
    return command.execute(*args, **defaults)
  File "/tests/django/django/core/management/base.py", line 458, in execute
    output = self.handle(*args, **options)
  File "/tests/django/django/contrib/staticfiles/management/commands/collectstatic.py", line 184, in handle
    if self.is_local_storage() and self.storage.location:
  File "/tests/django/django/contrib/staticfiles/management/commands/collectstatic.py", line 245, in is_local_storage
    return isinstance(self.storage, FileSystemStorage)
  File "/tests/django/django/utils/functional.py", line 280, in __getattribute__
    value = super().__getattribute__(name)
  File "/tests/django/django/utils/functional.py", line 251, in inner
    self._setup()
  File "/tests/django/django/contrib/staticfiles/storage.py", line 540, in _setup
    self._wrapped = storages[STATICFILES_STORAGE_ALIAS]
  File "/tests/django/django/core/files/storage/handler.py", line 43, in __getitem__
    storage = self.create_storage(params)
  File "/tests/django/django/core/files/storage/handler.py", line 55, in create_storage
    return storage_cls(**options)
  File "/tests/django/django/contrib/staticfiles/storage.py", line 463, in __init__
    self.hashed_files, self.manifest_hash = self.load_manifest()
  File "/tests/django/django/contrib/staticfiles/storage.py", line 484, in load_manifest
    raise ValueError(
ValueError: Couldn't load manifest 'staticfiles.json' (version 1.0)

Regards,
Jarek

Last edited 17 months ago by Jarosław Wygoda (previous) (diff)

comment:4 by Mariusz Felisiak, 17 months ago

In general, we don't support downgrade paths, e.g. sessions created in Django X may not work with Django < X etc.

comment:5 by Natalia Bidart, 17 months ago

Hello Jarek,

In addition to what Mariusz mentioned, I'm not being able to reproduce. I set the STORAGES as instructed and ran collectstatic on Django 4.2. The generated staticfiles.json has version 1.1 in it. I downgraded to Django 4.1 and ran collectstatic again, no errors.

comment:6 by Natalia Bidart, 17 months ago

Resolution: needsinfo
Status: newclosed

comment:7 by Jarosław Wygoda, 17 months ago

I think this change will improve the developer experience. People finding bugs after upgrading Django will have easier time reverting to previous version. Some parts of Django support downgrade paths, e.g. migrations.

comment:8 by Natalia Bidart, 16 months ago

Hello,

In my last comment I mentioned that I can not even reproduce the reported issue. Could you share a test project with clear steps to reproduce?

Thanks, Natalia.

comment:9 by Jarosław Wygoda, 16 months ago

Sorry I missed your comment. You can reproduce it by running ./manifest/manage.py collectstatic with django 3 here https://github.com/jwygoda/manifest/tree/master. See https://github.com/jwygoda/manifest/blob/master/test.sh for project setup.

I've also wrote a test reproducing this issue here: https://github.com/django/django/pull/17015/files#diff-5d0a445ee662a0619f13e7dfbc73f1de73b76ea5888e15bc0b1a20f32eccd8eaR904

Note: See TracTickets for help on using tickets.
Back to Top