@VisibleForTesting
  void validateStack() {
    Optional<StackId> requestStackId = request.getStackId();
    StackId stackId = requestStackId.orElseGet(cluster::getCurrentStackVersion);
    try {
      Stack stack = stackFactory.createStack(stackId.getStackName(), stackId.getStackVersion(), controller);
      state = state.with(stack);
    } catch (AmbariException e) {
      CHECK.wrapInUnchecked(e,
        requestStackId.isPresent() ? IllegalArgumentException::new : IllegalStateException::new,
        "Stack %s not found", stackId
      );
    }
  }
Create an {@link AddServiceInfo} based on the validated request.
ambari-server/src/main/java/org/apache/ambari/server/topology/addservice/RequestValidator.java