#33494: Collectstatic fails with Django 4 and 
SourcemapManifestStaticFilesStorage
------------------------------------------------+------------------------
               Reporter:  Felix Kleinekathöfer  |          Owner:  nobody
                   Type:  Bug                   |         Status:  new
              Component:  contrib.staticfiles   |        Version:  4.0
               Severity:  Normal                |       Keywords:
           Triage Stage:  Unreviewed            |      Has patch:  0
    Needs documentation:  0                     |    Needs tests:  0
Patch needs improvement:  0                     |  Easy pickings:  0
                  UI/UX:  0                     |
------------------------------------------------+------------------------
 I've tried updating a django app to 4.0. We are building our scripts with
 gulp which are then collected by
 Django. Here is an example script asset which is being picked up:

 {{{
 "use strict";

 (function () {
   // Automatically check "Uploaded avatar" radio button if user selects an
 avatar.
   Array.prototype.forEach.call(document.querySelectorAll('.avatar-image-
 upload'), function (el) {
     var form = el.closest('form');
     var radioButton =
 form.querySelector('input[type=radio][name=avatar_from][value=upload]');
     el.addEventListener('change', function () {
       if (el.value === '') return;
       radioButton.checked = true;
     });
   });
 })();

 //# sourceMappingURL=../../../../maps/spongeauth/static/scripts/app.js.map
 }}}

 This file worked well with Django 3 but now it ends up in a KeyError:

 {{{
 app_1    | + /home/spongeauth/env/bin/python spongeauth/manage.py
 collectstatic --noinput
 app_1    | Traceback (most recent call last):
 app_1    |   File "/home/spongeauth/app/spongeauth/manage.py", line 28, in
 <module>
 app_1    |     execute_from_command_line(sys.argv)
 app_1    |   File "/home/spongeauth/env/lib/python3.10/site-
 packages/django/core/management/__init__.py", line 425, in
 execute_from_command_line
 app_1    |     utility.execute()
 app_1    |   File "/home/spongeauth/env/lib/python3.10/site-
 packages/django/core/management/__init__.py", line 419, in execute
 app_1    |     self.fetch_command(subcommand).run_from_argv(self.argv)
 app_1    |   File "/home/spongeauth/env/lib/python3.10/site-
 packages/django/core/management/base.py", line 373, in run_from_argv
 app_1    |     self.execute(*args, **cmd_options)
 app_1    |   File "/home/spongeauth/env/lib/python3.10/site-
 packages/django/core/management/base.py", line 417, in execute
 app_1    |     output = self.handle(*args, **options)
 app_1    |   File "/home/spongeauth/env/lib/python3.10/site-
 packages/django/contrib/staticfiles/management/commands/collectstatic.py",
 line 187, in handle
 app_1    |     collected = self.collect()
 app_1    |   File "/home/spongeauth/env/lib/python3.10/site-
 packages/django/contrib/staticfiles/management/commands/collectstatic.py",
 line 128, in collect
 app_1    |     for original_path, processed_path, processed in processor:
 app_1    |   File "/home/spongeauth/env/lib/python3.10/site-
 packages/django/contrib/staticfiles/storage.py", line 426, in post_process
 app_1    |     yield from super().post_process(*args, **kwargs)
 app_1    |   File "/home/spongeauth/env/lib/python3.10/site-
 packages/django/contrib/staticfiles/storage.py", line 247, in post_process
 app_1    |     for name, hashed_name, processed, _ in
 self._post_process(paths, adjustable_paths, hashed_files):
 app_1    |   File "/home/spongeauth/env/lib/python3.10/site-
 packages/django/contrib/staticfiles/storage.py", line 312, in
 _post_process
 app_1    |     content = pattern.sub(converter, content)
 app_1    |   File "/home/spongeauth/env/lib/python3.10/site-
 packages/django/contrib/staticfiles/storage.py", line 173, in converter
 app_1    |     matched = matches['matched']
 app_1    | KeyError: 'matched'
 }}}

 I can't find a note on the migration docs that sourceFileMappingURLs need
 to be changed, so I suspect this being a bug.

 Source: https://github.com/SpongePowered/SpongeAuth/pull/926

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33494>
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/050.0ad0ca63dfc1003b07d5c243e0aa3d4f%40djangoproject.com.

Reply via email to