Error in contrasts<-(*tmp*, value = contr.funs[1 + isOF[nn]]) : contrasts can be applied only to factors with 2 or more levels

It's hard to pinpoint without a reproducible example, called a reprex, but a function expects a factor argument with two or more level and isn't seeing it.

Take a look at your environment

ls()

for objects that you know or suspect the function may be operating on, then

str(obj)

inspect the structure of the object. If there are factors, it will tell you how many levels.