core icon indicating copy to clipboard operation
core copied to clipboard

Dictionary lookup throws exception and halts automation latest HA update

Open erikeidt opened this issue 10 months ago • 3 comments

The problem

Automations that were working with 2025.2.5 are failing with 2025.3.2 (I skipped 2025.3 and 2025.3.1).

The failure is a dictionary lookup where the key/attribute is not found and the lookup is nested within a larger expression. For example,

{{ heat['attribute'] | float(0) + heat['attribute2'] | float(0) }}

With 2025.3.2 the automation is halted with an error message indicating missing attribute (it is indeed missing but this used continue without error using the default). With 2025.2.5, this would not yield an error, but instead provide the default value.

However, the following works in 2025.3.2 without error despite the attribute being missing.

temp1: "{{ heat['attribute'] }}"
temp2: "{{ heat['attribute2'] }}"
{{ temp1 | float(0) + temp2 | float(0) }}

This odd behavior: why would doing it into a variable work but the same in an expression cause a fault.

I thought this form name['attribute'] was never supposed to error on missing attribute, compared with name.attribute, which is expected to error on missing attribute.

This is also breaking change, meaning my automations have to be rewritten to work with the current version of HA.

And if the intent is to keep this strange change in behavior, you'll have to document the disparity in how it now works, such as the workaround above.

What version of Home Assistant Core has the issue?

core-2025.3.2

What was the last working version of Home Assistant Core?

core-2025.2.5

What type of installation are you running?

Home Assistant OS

Integration causing the issue

No response

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

{{ heat['attribute'] | float(0) + heat['attribute2'] | float(0) }}

#Note that the attribute is indeed missing, but this used to continue on with 2025.2 and prior.

Anything in the logs that might be useful for us?


Additional information

No response

erikeidt avatar Mar 13 '25 14:03 erikeidt

Hey there @petro31, @phracturedblue, @home-assistant/core, mind taking a look at this issue as it has been labeled with an integration (template) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of template can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign template Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


template documentation template source (message by IssueLinks)

home-assistant[bot] avatar Apr 20 '25 10:04 home-assistant[bot]

You have to provide more information. Please post the entire automation/script/template entity that this is used in so we can identify anything that may have changed.

Petro31 avatar Apr 20 '25 13:04 Petro31

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.