df_with_chain2array() uses ceiling(nrow(a) / n_chain) to compute the iteration dimension of the output array. When chains have unequal numbers of iterations, R's recycling rule silently duplicates rows to fill the gap, producing a corrupted MCMC array with no error or warning.
Reproducible example:
df <- data.frame(Chain = c(1L, 1L, 1L, 1L, 2L, 2L, 2L), V1 = 1:7)
# Chain 1 has 4 iterations, Chain 2 has 3
# ceiling(7/2) = 4, so chain 2's 3 rows get recycled to fill 4 slots