Template render error for non-exist code

Hi to all,

I started to get an error message about a template syntax error but… the code doesn’t exist anywhere. I have remove any old code, I have search all files (hidden or not) in all home assistant directory (even .storage) but to no avail. Restart also didn’t help. I can’t understand how to clean up this.
Any help?

Please share the error.

Keep in mind that templates you might have tested in the developers tool will also generate sticky errors

I was also thinking the same but the template editor has a different code for testing.
Btw: I’m aware that it is from Mushroom cards but… that cards/badge doesn’t exist anymore. I remove them all from all dashboards.

2024-09-17 12:12:21.793 ERROR (MainThread) [homeassistant.helpers.event] Error while processing template: Template<template=({% set temp=states(entity) %}
{% if temp > 26 %} 
red
{% elif (temp <= 26 && temp >= 23) %}
orange
{% elif temp < 26 %} 
green
{% endif %}) renders=248>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 547, in ensure_valid
    self._compiled_code = self._env.compile(self.template)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 3113, in compile
    compiled = super().compile(source)
               ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/jinja2/environment.py", line 768, in compile
    self.handle_exception(source=source_hint)
  File "/usr/local/lib/python3.12/site-packages/jinja2/environment.py", line 939, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<unknown>", line 4, in template
jinja2.exceptions.TemplateSyntaxError: unexpected char '&' at 74

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 715, in async_render_to_info
    render_info._result = self.async_render(  # noqa: SLF001
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 597, in async_render
    compiled = self._compiled or self._ensure_compiled(limited, strict, log_fn)
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 796, in _ensure_compiled
    self.ensure_valid()
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 549, in ensure_valid
    raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: TemplateSyntaxError: unexpected char '&' at 74

Use the word and not &&

Where? As I mention in OP I searched every single text file in all directories, hidden or not and there is no such code. The python error also doesn’t help additionally for the location.

This exists somewhere or it would not be throwing the error:

well… no. I removed all mushroom badges that had this code, I remove even the buttons that I copied the code. Except if there is something in binary data

It could also be as @koying writes.
Since a lot of updates ago, each browser tab remembers the template that is on it so any browser tab or device that has used this code in template editor will cause this error.

True but the moment that I post the error, I had one tab and the template editor has a completely different error. I will try to remove cookies if could be something.