We should not use .items[0].metadata.name if the array length is 0. This is the case when nothing has been initialized yet. Instead, we should use .items[*].metadata.name, the wildcard ensures to always return 0 even if nothing is present yet. Fixes: https://github.com/rook/rook/issues/8676 Signed-off-by: Sébastien Han <seb@redhat.com>