{"record":{"id":"01ff5404db81dc62","repo":"django/django","slug":"the-name-s-could-not-be-hashed-with-r","errorCode":null,"errorMessage":"The name '%s' could not be hashed with %r.","messagePattern":"The name '(.+?)' could not be hashed with %r\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"django/contrib/staticfiles/storage.py","lineNumber":533,"sourceCode":"        if cache_name:\n            return cache_name\n        # No cached name found, recalculate it from the files.\n        intermediate_name = name\n        for i in range(self.max_post_process_passes + 1):\n            cache_name = self.clean_name(\n                self.hashed_name(name, content=None, filename=intermediate_name)\n            )\n            if intermediate_name == cache_name:\n                # Store the hashed name if there was a miss.\n                self.hashed_files[hash_key] = cache_name\n                return cache_name\n            else:\n                # Move on to the next intermediate file.\n                intermediate_name = cache_name\n        # If the cache name can't be determined after the max number of passes,\n        # the intermediate files on disk may be corrupt; avoid an infinite\n        # loop.\n        raise ValueError(\"The name '%s' could not be hashed with %r.\" % (name, self))\n\n\nclass ManifestFilesMixin(HashedFilesMixin):\n    manifest_version = \"1.1\"  # the manifest format standard\n    manifest_name = \"staticfiles.json\"\n    manifest_strict = True\n    keep_intermediate_files = False\n\n    def __init__(self, *args, manifest_storage=None, **kwargs):\n        super().__init__(*args, **kwargs)\n        if manifest_storage is None:\n            manifest_storage = self\n        self.manifest_storage = manifest_storage\n        self.hashed_files, self.manifest_hash = self.load_manifest()\n\n    def read_manifest(self):\n        try:\n            with self.manifest_storage.open(self.manifest_name) as manifest:","sourceCodeStart":515,"sourceCodeEnd":551,"githubUrl":"https://github.com/django/django/blob/b5388a3a80cafcce2e34196d8e81cf5b48eb33bb/django/contrib/staticfiles/storage.py#L515-L551","documentation":"Raised in HashedFilesMixin._hashed_name (the hashed-name resolution loop) when the computed cache_name keeps changing across passes and never converges within max_post_process_passes (default 5). The comment says intermediate files on disk may be corrupt; this guard prevents an infinite loop.","triggerScenarios":"During collectstatic post-processing with keep_intermediate_files and hashed filenames, if each pass produces a different hashed name than the previous one for max_post_process_passes iterations. Typically caused by a CSS file referencing its own hashed output or a cyclic/chained reference that never stabilizes, or by corrupt intermediate files left in STATIC_ROOT.","commonSituations":"A CSS url() that points to a path that itself gets rewritten each pass (self-reference loop); leftover stale hashed files in STATIC_ROOT from a previous interrupted run; a custom storage overriding clean_name/hashed_name inconsistently.","solutions":["Clear STATIC_ROOT (delete the stale hashed/intermediate files) and re-run collectstatic.","Inspect the CSS/JS referenced in the error for self-referential or chained url() paths and fix them.","If you override HashedFilesMixin, ensure clean_name()/hashed_name() are deterministic (same input -> same output)."],"exampleFix":"# before -- stale hashed files cause non-converging passes\nmanage.py collectstatic  # -> ValueError could not be hashed\n\n# after -- wipe destination then re-run\nrm -rf /var/www/static/*\nmanage.py collectstatic --noinput","handlingStrategy":"fallback","validationCode":"import shutil\nfrom django.conf import settings\n\n# clear stale hashed/intermediate files before collectstatic\nshutil.rmtree(settings.STATIC_ROOT, ignore_errors=True)","typeGuard":null,"tryCatchPattern":"from django.core.management import call_command\nfrom django.core.management.base import CommandError\n\ntry:\n    call_command(\"collectstatic\", no_input=True, clear=True)\nexcept CommandError as e:\n    if \"could not be hashed\" in str(e):\n        call_command(\"collectstatic\", no_input=True, clear=True)\n    else:\n        raise","preventionTips":["Run collectstatic with --clear to wipe stale hashed/intermediate files.","Avoid self-referential url() loops in CSS that reference their own hashed output.","Keep custom HashedFilesMixin overrides deterministic."],"tags":["staticfiles","manifest","hashing","post-process","corruption"],"backgroundTag":null,"analyzedSha":"b5388a3a80cafcce2e34196d8e81cf5b48eb33bb","analyzedAt":"2026-08-10T17:37:52.993Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}