In my case, the issue was caused by an empty factor level in one of my categorical variables. Try to look for empty factor levels with table(dataset$factor_variable)!