Opened 4 weeks ago

Closed 4 weeks ago

Last modified 4 weeks ago

#35846 closed Cleanup/optimization (needsinfo)

Reproducibility of staticfiles manifests

Reported by: Linus Heckemann Owned by:
Component: contrib.staticfiles Version: 5.0
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Paths in staticfiles manifests appear in a nondeterministic order in the resulting JSON file. I assume this would often reflect the order in which files are listed by the operating system, given dict's insertion order preservation, but there are probably many more factors affecting this.

This can sometimes (but may not always -- this depends heavily on filesystem behaviour) be reproduced by running collectstatic in projects using ManifestStaticFilesStorage across different copies of the project source.

Sorting them would result in more comparable results, smaller diffs and (depending on the environment) more efficient deployments.

Change History (2)

comment:1 by Sarah Boyce, 4 weeks ago

Resolution: needsinfo
Status: newclosed

Hi Linus, would you be able to create a test project with some instructions as to how to reproduce this behavior?
If this is an issue we will need to be able to confirm it's fixed

comment:2 by Andreas Pelme, 4 weeks ago

It may be hard to show this exact problem since it depends on the OS/file systems used. The problem is the list of paths in the staticfiles manifest.

Somewhat related, see https://github.com/django/django/pull/16411/files#diff-f5c7100e3528e9f6edb98cd5a3d33133bdde6286a89fa472f89980fb07364a8eR486. It sorts the paths before hashing them. If it would not sort the keys, the hash could change. I tried changing sorted() to list() on that line and ran the test suite and there were no test failures. So testing this is a bit tricky to test properly!

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