{"record":{"id":"aff89c78068e88f7","repo":"nodejs/node","slug":"name","errorCode":null,"errorMessage":"{name}","messagePattern":"\\{name\\}","errorType":"exception","errorClass":"TemplateNotFound","httpStatus":null,"severity":"error","filePath":"tools/inspector_protocol/jinja2/loaders.py","lineNumber":366,"sourceCode":"\n    def get_source(self, environment, template):\n        loader, name = self.get_loader(template)\n        try:\n            return loader.get_source(environment, name)\n        except TemplateNotFound:\n            # re-raise the exception with the correct filename here.\n            # (the one that includes the prefix)\n            raise TemplateNotFound(template)\n\n    @internalcode\n    def load(self, environment, name, globals=None):\n        loader, local_name = self.get_loader(name)\n        try:\n            return loader.load(environment, local_name, globals)\n        except TemplateNotFound:\n            # re-raise the exception with the correct filename here.\n            # (the one that includes the prefix)\n            raise TemplateNotFound(name)\n\n    def list_templates(self):\n        result = []\n        for prefix, loader in iteritems(self.mapping):\n            for template in loader.list_templates():\n                result.append(prefix + self.delimiter + template)\n        return result\n\n\nclass ChoiceLoader(BaseLoader):\n    \"\"\"This loader works like the `PrefixLoader` just that no prefix is\n    specified.  If a template could not be found by one loader the next one\n    is tried.\n\n    >>> loader = ChoiceLoader([\n    ...     FileSystemLoader('/path/to/user/templates'),\n    ...     FileSystemLoader('/path/to/system/templates')\n    ... ])","sourceCodeStart":348,"sourceCodeEnd":384,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/tools/inspector_protocol/jinja2/loaders.py#L348-L384","documentation":"Same logic as error 624 but in PrefixLoader.load - the inner loader's load() raised TemplateNotFound for the local name, and PrefixLoader re-raises it with the original prefixed name so the caller sees the full path. load() differs from get_source() in that it returns a compiled Template object (and caches it).","triggerScenarios":"env.get_template('app1/missing.html') triggers load(); the prefix 'app1' resolves but the suffix 'missing.html' is not loadable by the inner loader. Bytecode cache stale after the file was renamed. Inner loader is a ModuleLoader whose compiled module is missing.","commonSituations":"Renaming a template without invalidating Environment's template cache (auto_reload disabled). Mixed loader strategies where some prefixes use precompiled modules that were not rebuilt.","solutions":["Set env.auto_reload=True (the default) or clear env.cache after deploying template changes.","Confirm the file exists for the inner loader by calling loader.mapping[prefix].get_source(env, suffix) directly.","If using ModuleLoader under a prefix, regenerate the compiled modules with jinja2-cli or compile_exports.","Check that the suffix uses the inner loader's expected path style."],"exampleFix":"// before\nenv = Environment(loader=PrefixLoader({'app1': ModuleLoader(mods)}), auto_reload=False)\n// after\nenv = Environment(loader=PrefixLoader({'app1': ModuleLoader(mods)}), auto_reload=True)\n# or rebuild the compiled module bundle after template edits","handlingStrategy":"try-catch","validationCode":"# verify the inner loader can load() before relying on PrefixLoader\nprefix, suffix = name.split(loader.delimiter, 1)\ninner = loader.mapping[prefix]\ninner.load(env, suffix)  # will raise the underlying TemplateNotFound here","typeGuard":"def prefix_loadable(loader, env, name: str) -> bool:\n    try:\n        loader.load(env, name)\n        return True\n    except Exception:\n        return False","tryCatchPattern":"from jinja2 import TemplateNotFound\ntry:\n    tpl = env.get_template(name)\nexcept TemplateNotFound:\n    env.cache.clear()  # in case of stale auto_reload=False cache\n    tpl = env.get_template(name)","preventionTips":["Leave env.auto_reload=True in development and after deploys.","If using ModuleLoader under a prefix, regenerate modules as a deploy step.","On deploy, clear Jinja2's bytecode cache so removals/renames are reflected."],"tags":["jinja2","template-not-found","prefix-loader","load","cache"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}