For whom it might help: I have encountered this error when I tried to group documents by several fields where one of them was a boolean field. After I removed the boolean field from the group _id expression, the error was gone.