{% set item = collection ?? object %}
{% set type = collection ? 'collection' : 'object' %}

ERROR: Layout '{{ layout }}' for flex {{ type }} '{{ item.flexType() }}'  was not found.