iantrich / config-template-card

📝 Templatable Lovelace Configurations
MIT License
434 stars 56 forks source link

Card throws exception "Cannot read property 'includes' of null" #67

Closed kamtschatka closed 3 years ago

kamtschatka commented 3 years ago

Checklist:

Release with the issue:

1.3.0

Last working release (if known):

Browser and Operating System:

I am using Chrome and Windows, but should not matter

Description of problem:

There is an exception flickering all the time, because the "template" parameter for the _evaluateTemplate function is either null or an object with the property "entity"(like this: {entity: ""})

Javascript errors shown in the web inspector (if applicable):

5VM33232 config-template-card.js:3372 Uncaught (in promise) TypeError: Cannot read property 'includes' of null
    at HTMLElement._evaluateTemplate (VM33232 config-template-card.js:3372)
    at VM33232 config-template-card.js:3294
    at Array.forEach (<anonymous>)
    at HTMLElement.shouldUpdate (VM33232 config-template-card.js:3290)
    at HTMLElement.performUpdate (VM33232 config-template-card.js:2414)
    at HTMLElement._enqueueUpdate (VM33232 config-template-card.js:2369)

Additional information:

The null check at this location is rather simple, but I am not sure if the object should go through the rest of the function or not. I am guessing not?

        if (!template || !template.includes || !template.includes('${')) {
            return template;
        }
kamtschatka commented 3 years ago

Did some more debugging on this case and it was caused by a change in the auto-entities card that I made locally. Sorry for the false alarm.