# Troubleshooting a Django collectstatic Error After Upgrading to Version 4.2.

**URL:** <https://forum.djangoproject.com/t/troubleshooting-a-django-collectstatic-error-after-upgrading-to-version-4-2/23810>\
**Category:** Mystery Errors\
**Created:** [September 12, 2023, 6:46am UTC](https://forum.djangoproject.com/t/troubleshooting-a-django-collectstatic-error-after-upgrading-to-version-4-2/23810 "2023-09-12T06:46:50Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![DevMaster15](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/devmaster15/32/15869_2.png) [@DevMaster15](https://forum.djangoproject.com/u/DevMaster15)\
**Post date:** [September 12, 2023, 6:46am UTC](https://forum.djangoproject.com/t/troubleshooting-a-django-collectstatic-error-after-upgrading-to-version-4-2/23810/1 "2023-09-12T06:46:51Z")

</div>

Greetings!

I’m encountering an issue with the `collectstatic` command, which persisted until I upgraded Django to version 4.2. When I execute `./manage.py collectstatic`, it throws an error that says:  
“`my_path/my.map`’ could not be found with `<project.assets.CustomStorage object at 0x7f1af8be4370>`,”

and I’m struggling to understand the cause.

In my `settings.py` file, I’ve configured the `STORAGES` dictionary for static files as follows:

```auto
STORAGES["staticfiles"] = {"BACKEND": "project.assets.CustomStorage"}

```

Where `CustomStorage` is a custom class defined as:

```auto
class CustomStorage(ManifestFilesMixin, S3Boto3Storage):
    location = settings.AWS_ASSETS_BUCKET_FOLDER
    querystring_auth = False
    bucket_name = settings.AWS_ASSETS_BUCKET_NAME

```

Would you be able to assist me in resolving this issue?

---

<div class="post-metadata">

**Author:** ![harryghgim](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/harryghgim/32/5698_2.png) [@harryghgim](https://forum.djangoproject.com/u/harryghgim)\
**Post date:** [November 9, 2023, 11:39am UTC](https://forum.djangoproject.com/t/troubleshooting-a-django-collectstatic-error-after-upgrading-to-version-4-2/23810/2 "2023-11-09T11:39:46Z")

</div>

Same issue here.

This occurs when I use S3Boto3Storage with ManifestFilesMixin.

I use django 4.2, python3.11, django-storages 1.13.2.

---

<div class="post-metadata">

**Author:** ![harryghgim](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/harryghgim/32/5698_2.png) [@harryghgim](https://forum.djangoproject.com/u/harryghgim)\
**Post date:** [November 11, 2023, 3:08pm UTC](https://forum.djangoproject.com/t/troubleshooting-a-django-collectstatic-error-after-upgrading-to-version-4-2/23810/3 "2023-11-11T15:08:40Z")

</div>

I think I found a pattern here. It seems django is trying to find file that has `.map` extension.

For me the missing file that django couldn’t find is `swiper-bundle.min.js`

```auto
Post-processing 'js/3rdparty/swiper-bundle.min.js' failed!
....
ValueError: The file 'js/3rdparty/swiper-bundle.min.js.map' could not be found with <company.storage.StaticS3Storage object at 0x7f7823ab8850>.

```

Not much a progress to be honest though.

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [November 11, 2023, 3:24pm UTC](https://forum.djangoproject.com/t/troubleshooting-a-django-collectstatic-error-after-upgrading-to-version-4-2/23810/4 "2023-11-11T15:24:16Z")

</div>

> [@harryghgim](#):
>
> For me the missing file that django couldn’t find is `swiper-bundle.min.js`

I don’t think that’s the case here. I think it’s finding _that_ file, but not finding the related map file.

I’m guessing that the storage class is either using the [ManifestStaticFilesStorage](https://docs.djangoproject.com/en/4.2/ref/contrib/staticfiles/#django.contrib.staticfiles.storage.ManifestStaticFilesStorage) class or doing the same thing as this class regarding map files. (The docs specify that the map files are processed by this class.)

Look for a file by that name in that third-party package and include it in your project.

---

<div class="post-metadata">

**Author:** ![harryghgim](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/harryghgim/32/5698_2.png) [@harryghgim](https://forum.djangoproject.com/u/harryghgim)\
**Post date:** [November 11, 2023, 3:34pm UTC](https://forum.djangoproject.com/t/troubleshooting-a-django-collectstatic-error-after-upgrading-to-version-4-2/23810/5 "2023-11-11T15:34:57Z")

</div>

Thanks for reaching me out.

I did check whether the file exists.

First it does exist in s3 bucket.

![Screenshot 2023-11-12 at 12.28.14 AM](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/3X/6/0/60f4ee3743aa31de20ae59f8811e11a9ef282b07.png)

Secondly, the file also exists in my project.

 ![Screenshot 2023-11-12 at 12.29.44 AM](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/3X/9/8/983085330f6176833138baeb6e89dacde512c2e6.png)

So I’m clueless what’s actually going on here.

# Updates

As I was browsing [the document](https://docs.djangoproject.com/en/4.2/ref/contrib/staticfiles/#django.contrib.staticfiles.storage.ManifestStaticFilesStorage.manifest_strict), I noticed the following section:

> If a file isn’t found in the `staticfiles.json` manifest at runtime, a `ValueError` is raised. This behavior can be disabled by subclassing `ManifestStaticFilesStorage` and setting the `manifest_strict` attribute to `False` – nonexistent paths will remain unchanged.

So if I set the attribute False aforementioned, what risks could there be?

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [November 11, 2023, 3:46pm UTC](https://forum.djangoproject.com/t/troubleshooting-a-django-collectstatic-error-after-upgrading-to-version-4-2/23810/6 "2023-11-11T15:46:27Z")

</div>

Yes, the .js file exists. What about the .js.map file? That’s what the message is telling you is missing.

---

<div class="post-metadata">

**Author:** ![harryghgim](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/harryghgim/32/5698_2.png) [@harryghgim](https://forum.djangoproject.com/u/harryghgim)\
**Post date:** [November 11, 2023, 3:50pm UTC](https://forum.djangoproject.com/t/troubleshooting-a-django-collectstatic-error-after-upgrading-to-version-4-2/23810/7 "2023-11-11T15:50:13Z")

</div>

Forget about what I wrote on `manifest_strict`. The error seems to happen regardless of the attribute.

```auto
# django.contrib.staticfiles.storage.py
class ManifestFilesMixin(HashedFilesMixin):
    ...
    def stored_name(self, name):
        ...
        cache_name = self.hashed_files.get(hash_key)
        if cache_name is None:
            if self.manifest_strict:
                raise ValueError(
                    "Missing staticfiles manifest entry for '%s'" % clean_name
                )
            cache_name = self.clean_name(self.hashed_name(name)) # thread gets in hased_name method first
    ...

```

```auto
# django.contrib.staticfiles.storage.py
class HashedFilesMixin:
    ...
    def hashed_name(self, name, content=None, filename=None):
        ...
        if opened:
            if not self.exists(filename):
                raise ValueError(
                    "The file '%s' could not be found with %r." % (filename, self) # and error occurs here
                )
            try:
                content = self.open(filename)
            except OSError:
                # Handle directory paths and fragments
                return name

```

As the comments in the code snippet stated, the error would have occured anyway even if I had set manifest\_strict True.

---

<div class="post-metadata">

**Author:** ![harryghgim](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/harryghgim/32/5698_2.png) [@harryghgim](https://forum.djangoproject.com/u/harryghgim)\
**Post date:** [November 11, 2023, 3:53pm UTC](https://forum.djangoproject.com/t/troubleshooting-a-django-collectstatic-error-after-upgrading-to-version-4-2/23810/8 "2023-11-11T15:53:10Z")

</div>

`.map` file doesn’t exist neither in my proejct static nor s3 bucket. It never did.

I’m not sure why django is looking for the map extension.

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [November 11, 2023, 4:04pm UTC](https://forum.djangoproject.com/t/troubleshooting-a-django-collectstatic-error-after-upgrading-to-version-4-2/23810/9 "2023-11-11T16:04:01Z")

</div>

> [@harryghgim](#):
>
> I’m not sure why django is looking for the map extension.

That’s one I can’t answer beyond the fact that the docs mention that those files are included in the regex being used to look for files. I’d check to see if that file is available from whatever your source is for this package.

(I can also mention that we’ve gotten around errors related to map files in the past by just creating a blank file with the right name. We’ve never needed a real map file.)

---

<div class="post-metadata">

**Author:** ![harryghgim](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/harryghgim/32/5698_2.png) [@harryghgim](https://forum.djangoproject.com/u/harryghgim)\
**Post date:** [November 12, 2023, 4:13pm UTC](https://forum.djangoproject.com/t/troubleshooting-a-django-collectstatic-error-after-upgrading-to-version-4-2/23810/10 "2023-11-12T16:13:22Z")

</div>

I figured out what went wrong.

It’s true that my project does not have .map file. But the name of the file was written in one of the files as comment.

```auto
//# sourceMappingURL=js/3rdparty/swiper-bundle.min.js.map

```

I had quite a good number of files with such comments. Besides, I had css files that reference image file as url but does not exist in reality.

After I removed all the wrong lines from files, post\_process finally stopped complaining.

Thank you all!
