Conversation
| tpl.hass = hass | ||
| resp[key] = tpl.async_render(item.get(ATTR_TEMPLATE_VARIABLES)) | ||
| except TemplateError as ex: | ||
| except Exception as ex: # pylint: disable=broad-except |
There was a problem hiding this comment.
@bdraco this is a little weird I think. We need to catch all exceptions because template {{ now() | random }} raises a TypeError that crashes the websocket connection (500 error) and also here had to be caught with a generic error. Should we catch all exceptions that come out of render and wrap it in TemplateError ?
There was a problem hiding this comment.
Wrapping .render in template.py seems like it will also fix some other bugs where templates stop updating because the exception isn't trapped.
I'm doing testing with it now.
There was a problem hiding this comment.
It also looks like {{ now() | rando }} is untrapped.
There was a problem hiding this comment.
I've found a few things. I'll open a new PR to fix them, when its done trapping except TemplateError as ex will do what was originally expected here.
Co-authored-by: J. Nick Koston <nick@koston.org>
e07dd85 to
c72aba0
Compare
Co-authored-by: J. Nick Koston <nick@koston.org>
Breaking change
Proposed change
Rendering templates via the mobile app was a little cumbersome. Invalid templates would fail the payload and errors in templates would propagate up.
This makes sure we catch them all.
Note, our current template return type is a little problematic, since starting with 117 we will be able to return native values from templates, and so the user could return a similar shaped error object from a template 🤔
CC @zacwest
Type of change
Example entry for
configuration.yaml:# Example configuration.yamlAdditional information
Checklist
black --fast homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all..coveragerc.The integration reached or maintains the following Integration Quality Scale:
To help with the load of incoming pull requests: