Opened 32 hours ago

Closed 6 hours ago

#36236 closed Bug (duplicate)

collectstatic doesn't ignore comments or --ignore for hashing

Reported by: ElJeffe Owned by:
Component: File uploads/storage Version: 5.1
Severity: Normal Keywords: collectstatic, ManifestStaticFilesStorage
Cc: ElJeffe Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description (last modified by ElJeffe)

I have some static vendor files that include commented out map files, which causes a value error on hashing. Since it's commented, shouldn't it be ignored. If not, shouldn't it be ignored if I include --ignore 'js.map'. Neither of those happen, which causes an error when trying to use ManifestStaticFilesStorage.

//# sourceMappingURL=moment-with-locales.min.js.map
/*# sourceMappingURL=bootstrap.min.css.map */

Update: I've run into other fonts or images that are referenced and missing in vendor packages. If a file is missing during the hashing, can it just be skipped instead of raising an error? This is not a linter.. do what is there, don't fail it.


Post-processing 'theme/vendor/daterangepicker/node_modules/moment/min/moment-with-locales.min.js' failed!

Traceback (most recent call last):
  File "/opt/pioneer/manage.py", line 24, in <module>
    main()
    ~~~~^^
  File "/opt/pioneer/manage.py", line 20, in main
    execute_from_command_line(sys.argv)
    ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
    ~~~~~~~~~~~~~~~^^
  File "/usr/local/lib/python3.13/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/django/core/management/base.py", line 413, in run_from_argv
    self.execute(*args, **cmd_options)
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/django/core/management/base.py", line 459, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.13/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 209, in handle
    collected = self.collect()
  File "/usr/local/lib/python3.13/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 154, in collect
    raise processed
  File "/usr/local/lib/python3.13/site-packages/django/contrib/staticfiles/storage.py", line 375, in _post_process
    content = pattern.sub(converter, content)
  File "/usr/local/lib/python3.13/site-packages/django/contrib/staticfiles/storage.py", line 249, in converter
    hashed_url = self._url(
        self._stored_name,
    ...<2 lines>...
        hashed_files=hashed_files,
    )
  File "/usr/local/lib/python3.13/site-packages/django/contrib/staticfiles/storage.py", line 182, in _url
    hashed_name = hashed_name_func(*args)
  File "/usr/local/lib/python3.13/site-packages/django/contrib/staticfiles/storage.py", line 425, in _stored_name
    cache_name = self.clean_name(self.hashed_name(name))
                                 ~~~~~~~~~~~~~~~~^^^^^^
  File "/usr/local/lib/python3.13/site-packages/django/contrib/staticfiles/storage.py", line 143, in hashed_name
    raise ValueError(
        "The file '%s' could not be found with %r." % (filename, self)
    )
ValueError: The file 'theme/vendor/daterangepicker/node_modules/moment/min/moment-with-locales.min.js.map' could not be found with <django.contrib.staticfiles.storage.ManifestStaticFilesStorage object at 0xffffa4016900>.

Change History (9)

comment:1 by ElJeffe, 32 hours ago

Description: modified (diff)

comment:2 by ElJeffe, 32 hours ago

Description: modified (diff)

comment:3 by ElJeffe, 32 hours ago

Summary: collectstatic doesn't ignore commentscollectstatic doesn't ignore comments or --ignore for hashing

comment:4 by ElJeffe, 17 hours ago

Description: modified (diff)

comment:5 by ElJeffe, 8 hours ago

Description: modified (diff)

comment:6 by ElJeffe, 8 hours ago

Description: modified (diff)

comment:7 by ElJeffe, 8 hours ago

Description: modified (diff)

comment:8 by ElJeffe, 7 hours ago

Description: modified (diff)

comment:9 by Mariusz Felisiak, 6 hours ago

Resolution: duplicate
Status: newclosed

Duplicate of #21080.

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