home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
69.47k stars 28.67k forks source link

Some log warnings and errors are ambiguous for source #117025

Open def1149 opened 1 month ago

def1149 commented 1 month ago

The problem

I have some warnings in my log that do not contain enough context information to locate the source of the error. This makes it impossible to determine who to report the warning to. See examples below. I've tediously checked all my scripts and templates and can't find any code that matches that in the log. I tried enabling debug for all integrations but the logger very quickly created hundreds of megabytes. Enabling debug one by one is tedious and time-wasting process for rarely occurring warnings or errors

The solution: All warnings and errors must provide sufficient context information to allow the user to locate the source of the problem quickly, efficiently, and accurately identify the source of the problem. A coding standard for handling error and warming logging and enforcement as part of QC needs to be created,

What version of Home Assistant Core has the issue?

2024.5.2

What was the last working version of Home Assistant Core?

??

What type of installation are you running?

Home Assistant OS

Integration causing the issue

??

Link to integration documentation on our website

No response

Diagnostics information

` Logger: homeassistant.helpers.script Source: helpers/script.py:824 First occurred: 10:47:23 AM (3 occurrences) Last logged: 10:48:36 AM

Error in 'if[0]' evaluation: In 'template' condition: TypeError: '>' not supported between instances of 'int' and 'dict'

Logger: homeassistant.helpers.template Source: helpers/template.py:2613 First occurred: 10:48:29 AM (8 occurrences) Last logged: 10:48:47 AM

Template variable warning: 'update' is undefined when rendering '{{ iif(update, 'none', sound) }}' Template variable warning: 'update' is undefined when rendering '{{ iif((update or sound == 'none'), 0, volume) }} `

Example YAML snippet

N/A

Anything in the logs that might be useful for us?

above

Additional information

None

joostlek commented 1 month ago

Both are template issues from the looks of it

def1149 commented 1 month ago

I finally found the source. These errors came from code created by a Blueprint! Very tedious to find. I had to load the 'automation config', the code, from a trace of the BP automation and search for text.

As I said, ALL errors must provide sufficient origin context so the source can be easily and quickly identified. Cleary HA "knew" what automation was executing when the errors occurred but the error logger didn't capture and report that

I believe this is a bug in the error logger