"Ex opere operato" and geirut
Apparently the Catholic church dealt with a very similar issue:
Ex opere operato is a Latin phrase meaning "from the work worked" referring to the efficacy of the Sacraments deriving from the action of the Sacrament as opposed to the merits or holiness of the priest or participant. In modern usage, the phrase often refers to the idea that sacraments are efficacious in and of themselves rather than depending on the attitude either of the minister or the recipient. For example, Confirmation might be held to bestow the Holy Spirit regardless of the attitude of both the bishop and the person being confirmed.
In antiquity, the idea led to a schism among the Donatist Christians. The Donatists held that "one of the three bishops who had consecrated Caecilian was a traditor", and therefore, Caecilian's consecration was invalid. They furthermore held "that the validity of such an act depended on the worthiness of the bishop performing it" and Caecilian and his followers "responded that the validity of the sacraments and of other such acts cannot be made to depend on the worthiness of the one administering them, for in that case all Christians would be in constant doubt regarding the validity of their own baptism or of the communion of which they had partaken."
Today, according to the teaching of the Catholic Church, to make the fruits of the sacraments requires that a person be properly disposed. This means use of sufficient grace via the sacraments is not automatic. There must be, at least in the case of an adult, an openness to use the sufficient grace which is available in a sacrament. When the recipient is properly disposed, the sufficient grace of the sacrament is efficacious.
This principle holds that the efficacy of the sacrament is a result, not of the holiness of a priest or minister, but rather of Christ Himself who is the Author (directly or indirectly) of each sacrament. The priest or minister acts "in persona Christi" (in the person of Christ) even if in a state of mortal sin. Although such a sacrament would be valid, and the grace efficacious, it is nonetheless sinful for any priest to celebrate a sacrament while himself in a state of mortal sin.
The principle of ex opere operato affirms that while a proper disposition (openness) is necessary to exercise the efficacious grace in the sacraments, it is not the cause of the sufficient grace. Catholic Christians believe that what God offers in the sacraments is a gift, freely bestowed out of God’s own love. A person's disposition, as good as it may be, does not automatically bring God's blessing.
In the Anglican Communion, the principle of "ex opere operato" is made conditional upon worthy reception. Article XXVI of the Thirty-nine Articles (Of the unworthiness of ministers which hinders not the effect of the Sacrament) states that the ministration of the Word (Scripture) and sacraments is not done in the name of the priest or minister and that the efficacy of Christ's sacraments is not taken away, nor God’s grace diminished by the sinfulness of clergy. This is because sacraments have their efficacy due to Christ’s promise to His Church.