home-assistant / frontend

:lollipop: Frontend for Home Assistant
https://demo.home-assistant.io
Other
4.07k stars 2.79k forks source link

"Trace Timeline" throws exceptions for `repeat` action #21938

Open Guyohms opened 2 months ago

Guyohms commented 2 months ago

Checklist

Describe the issue you are experiencing

On several of my automations, when I need to troubleshoot it, I find myself with an empty "Trace Timeline". I can see the steps details, download the trace in json format but the "Trace Timeline" tab is empty.

image

It seems to happen more frequently when using a repeat, while. Here's the most basic automation I've been able to write that causes this issue.

alias: New automation
description: ''
trigger: []
condition: []
action:
  - repeat:
      sequence:
        - stop: test
      while:
        - condition: state
          entity_id: input_boolean.test
          state: 'on'
mode: single

It seems to happen more frequently when using a repeat, while. Maybe it's backend related, but I'll report it here since the automation works and the trace is generated for download.

Describe the behavior you expected

See the trace timeline as with any other automations

Steps to reproduce the issue

  1. Write a new automation using the UI with a Reapeat/While
  2. Add a stop action
  3. Run
  4. Check the "Trace Timeline". It should be empty

What version of Home Assistant Core has the issue?

2024.9.1

What was the last working version of Home Assistant Core?

No response

In which browser are you experiencing the issue with?

Google Chrome 128.0.6613.120

Which operating system are you using to run this browser?

Windows 10

State of relevant entities

No response

Problem-relevant frontend configuration

No response

Javascript errors shown in your browser console/inspector

No response

Additional information

No response

karwosts commented 2 months ago

Can you download the trace in question and attach it here?

Guyohms commented 2 months ago

Yes! Here it is! trace automation.new_automation 2024-09-10T00_41_55.556417+00_00.json

Guyohms commented 2 months ago

It could also be related to this issue as well. https://github.com/home-assistant/frontend/issues/15348

karwosts commented 2 months ago

I do see this is throwing exceptions which is why it is not rendering. Couldn't quite figure out how this code is structured though.

script.ts:362 Uncaught (in promise) TypeError: Cannot use 'in' operator to search for 'delay' in input_boolean.test
    at getActionType (script.ts:362:1)
    at ActionRenderer._handleSequence (hat-trace-timeline.ts:612:1)
    at ActionRenderer._renderIteration (hat-trace-timeline.ts:315:1)
    at eval (hat-trace-timeline.ts:244:1)
    at Array.forEach (<anonymous>)
    at ActionRenderer._renderItem (hat-trace-timeline.ts:243:1)
    at ActionRenderer._handleRepeat (hat-trace-timeline.ts:517:1)
    at ActionRenderer._renderIteration (hat-trace-timeline.ts:307:1)
    at ActionRenderer._renderItem (hat-trace-timeline.ts:248:1)
    at ActionRenderer.renderItem (hat-trace-timeline.ts:227:1)
silamon commented 2 months ago

It looks like a backend issue, since the trace marks the entity id as an action. That's also what the error is about. Need to look further into this how it works.