[backport] fix NPEs in CollectionContainer and CollectionItem