This template works without error when passed payload "Tuesday" :
<template>
<div>
<h2>No errors here</h2>
<p>Today is {{msg.payload}}</p>
</div>
</template>

But this template gives a console error errorCaptured TypeError: can't access property "dinner", msg.payload is undefined when passed payload
{
"breakfast": "Croissant",
"lunch": "Sandwiches",
"dinner": "Steak"
}
<template>
<div>
<h2>Check the console!</h2>
<p>Dinner will be {{msg.payload.dinner}}</p>
</div>
</template>
NB the dashboard still shows the desired output

It seems like the code is initially parsed before msg.payload has a value, then again when the message arrives. But that doesn't explain why there is no error in the first example.
Is this a bug or deliberate?
There are a bunch of work-arounds. Probably the simplest is to use "Optional chaining" to pass message properties. NB the fallback value (here an empty string) is essential. :
<p>Dinner will be {{msg?.payload?.dinner ?? '' }}</p>
Is there any reason why the ui-template code can't do this optional chaining, or protect the object with v-if, or otherwise, automatically in the background?