public void validateMember(
        String memberId,
        String groupInstanceId,
        String operation
    ) throws UnknownMemberIdException, FencedInstanceIdException {
        if (groupInstanceId != null) {
            String existingMemberId = staticMemberId(groupInstanceId);
            if (existingMemberId == null) {
                throw Errors.UNKNOWN_MEMBER_ID.exception();
            } else if (!existingMemberId.equals(memberId)) {
                log.info("Request memberId={} for static member with groupInstanceId={} " +
                         "is fenced by existing memberId={} during operation {}",
                    memberId, groupInstanceId, existingMemberId, operation);
                throw Errors.FENCED_INSTANCE_ID.exception();
            }
        }

        if (!hasMember(memberId)) {
            throw Errors.UNKNOWN_MEMBER_ID.exception();
        }
    }
Validates that (1) the group instance id exists and is mapped to the member id
if the group instance id is provided; and (2) the member id exists in the group.

@param memberId          The member id.
@param groupInstanceId   The group instance id.
@param operation         The operation.

@throws UnknownMemberIdException
@throws FencedInstanceIdException
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/classic/ClassicGroup.java