if node.exists and not isinstance(old_val, list):
                value_type = type(old_val).__name__
                msg = (
                    "Cannot apply $addToSet to non-array field. Field "
                    "named {0!r} has non-array type {1}"