frenck / spook

A scary 👻 powerful toolbox 🧰 for Home Assistant 🏡
https://spook.boo
MIT License
381 stars 36 forks source link

Unexpected exception from <function AbstractSpookRepair.async_activate.<locals>._async_inspect at 0x7f55e8c720> #615

Closed Snuffy2 closed 3 months ago

Snuffy2 commented 3 months ago

What version of Spook are you using?

v2.2.1

What version of Home Assistant are you using?

2024.2.1

The problem

I was seeing this error more in 2.2.0, but it is still appearing in v2.2.1 albeit less so. Not sure if it is affecting any functionality.

2024-02-11 15:54:53.468 ERROR (MainThread) [custom_components.spook] Unexpected exception from <function AbstractSpookRepair.async_activate.<locals>._async_inspect at 0x7f55e8c720>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/debounce.py", line 114, in _handle_timer_finish
    await task
  File "/config/custom_components/spook/repairs.py", line 149, in _async_inspect
    await self.async_inspect()
  File "/config/custom_components/spook/ectoplasms/automation/repairs/unknown_service_references.py", line 47, in async_inspect
    services=async_find_services_in_sequence(entity.action_script.sequence),
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/spook/util.py", line 260, in async_find_services_in_sequence
    called_services.add(step[CONF_SERVICE])
                        ~~~~^^^^^^^^^^^^^^
KeyError: 'service'

Anything in the logs? Paste it here!

spook_log.log

codyc1515 commented 3 months ago

Similar issue here:

This error originated from a custom integration.

Logger: custom_components.spook
Source: helpers/debounce.py:114
Integration: Spook (documentation, issues)
First occurred: 00:02:00 (40 occurrences)
Last logged: 14:49:01

Unexpected exception from <function AbstractSpookRepair.async_activate.<locals>._async_inspect at 0x7f5fcdba60>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/debounce.py", line 114, in _handle_timer_finish
    await task
  File "/config/custom_components/spook/repairs.py", line 134, in _async_inspect
    await self.async_inspect()
  File "/config/custom_components/spook/ectoplasms/automation/repairs/unknown_service_references.py", line 67, in async_inspect
    _async_find_services_in_sequence(
  File "/config/custom_components/spook/ectoplasms/automation/repairs/unknown_service_references.py", line 120, in _async_find_services_in_sequence
    _async_find_services_in_sequence(called_services, choice[CONF_SEQUENCE])
  File "/config/custom_components/spook/ectoplasms/automation/repairs/unknown_service_references.py", line 136, in _async_find_services_in_sequence
    _async_find_services_in_sequence(called_services, step[CONF_SEQUENCE])
                                                      ~~~~^^^^^^^^^^^^^^^
KeyError: 'sequence'
frenck commented 3 months ago

@codyc1515 Yours isn't the same / isn't related, and was fixed in the latest version. Please update :)

frenck commented 3 months ago

Hmmm @Snuffy2 Do you happen to use service_template in any of your automations?

../Frenck

DarwinData commented 3 months ago

I am using spook and really like it. I am getting this same error even after updating to 2.2.1 and HA core at 2024.2.1 fyi, I AM using service_template. thanks for all of your work!

frenck commented 3 months ago

Thanks, @DarwinData that confirms my suspicions. Will ship a bug fix later tonight.

../Frenck

DarwinData commented 3 months ago

Thanks for the quick fix!

frenck commented 3 months ago

No problem ❤️

Snuffy2 commented 3 months ago

I don't see any remaining use of service_template in my automations, scripts, switches, etc. but there may be some I'm missing. I'll gladly give #617 a try to see if it fixes it though.

frenck commented 3 months ago

@Snuffy2 Let me know! Otherwise, we'll keep digging 😄

Snuffy2 commented 3 months ago

I grep'd the directory and apparently service_template is still being used by https://github.com/FutureTense/keymaster which I do use.

frenck commented 3 months ago

If that is the root cause, upgrading to Spook v2.2.2 should resolve your issue.

Snuffy2 commented 3 months ago

Yep, v2.2.2 is working and I am no longer seeing the error in the logs. Thanks for the quick fix!

frenck commented 3 months ago

Awesome! Thanks for letting me know ❤️

(and for reporting this issue in the first place of course 😄 )

../Frenck