Program: 110961
Project: 110961
Buggy source:
/** 
 * Constructs an   {@link EvaluationResult} from the {@link #graph}.  Looks for cycles if there are unfinished nodes but no error was already found through bubbling up (as indicated by   {@code bubbleErrorInfo} being null).<p> {@code visitor} may be null, but only in the case where all graph entries corresponding to{@code skyKeys} are known to be in the DONE state ({@code entry.isDone()} returns true).
 */
private <T extends SkyValue>EvaluationResult<T> constructResult(@Nullable ValueVisitor visitor,Iterable<SkyKey> skyKeys,@Nullable Map<SkyKey,ValueWithMetadata> bubbleErrorInfo,boolean catastrophe){
  Preconditions.checkState(catastrophe == (keepGoing && bubbleErrorInfo != null),"String_Node_Str",skyKeys,catastrophe,keepGoing,bubbleErrorInfo);
  EvaluationResult.Builder<T> result=EvaluationResult.builder();
  List<SkyKey> cycleRoots=new ArrayList<>();
  boolean hasError=false;
  for (  SkyKey skyKey : skyKeys) {
    ValueWithMetadata valueWithMetadata=getValueMaybeFromError(skyKey,bubbleErrorInfo);
    if (valueWithMetadata == null) {
      if (bubbleErrorInfo == null) {
        cycleRoots.add(skyKey);
      }
      hasError=true;
      continue;
    }
    SkyValue value=valueWithMetadata.getValue();
    replayingNestedSetEventVisitor.visit(valueWithMetadata.getTransitiveEvents());
    ErrorInfo errorInfo=valueWithMetadata.getErrorInfo();
    Preconditions.checkState(value != null || errorInfo != null,skyKey);
    hasError=hasError || (errorInfo != null);
    if (!keepGoing && errorInfo != null) {
      result.addError(skyKey,errorInfo);
      continue;
    }
    if (value == null) {
      result.addError(skyKey,errorInfo);
    }
 else {
      result.addResult(skyKey,value);
    }
  }
  if (!cycleRoots.isEmpty()) {
    Preconditions.checkState(visitor != null,skyKeys);
    checkForCycles(cycleRoots,result,visitor,keepGoing);
  }
  Preconditions.checkState(bubbleErrorInfo == null || hasError,"String_Node_Str",bubbleErrorInfo,skyKeys);
  result.setHasError(hasError);
  if (catastrophe) {
    ErrorInfo errorInfo=Preconditions.checkNotNull(Iterables.getOnlyElement(bubbleErrorInfo.values()).getErrorInfo(),"String_Node_Str",bubbleErrorInfo);
    Preconditions.checkState(errorInfo.isCatastrophic(),"String_Node_Str",bubbleErrorInfo);
    result.setCatastrophe(errorInfo.getException());
  }
  return result.build();
}

Fixed version (ground truth):
/** 
 * Constructs an   {@link EvaluationResult} from the {@link #graph}.  Looks for cycles if there are unfinished nodes but no error was already found through bubbling up (as indicated by   {@code bubbleErrorInfo} being null).<p> {@code visitor} may be null, but only in the case where all graph entries corresponding to{@code skyKeys} are known to be in the DONE state ({@code entry.isDone()} returns true).
 */
private <T extends SkyValue>EvaluationResult<T> constructResult(@Nullable ValueVisitor visitor,Iterable<SkyKey> skyKeys,@Nullable Map<SkyKey,ValueWithMetadata> bubbleErrorInfo,boolean catastrophe){
  Preconditions.checkState(catastrophe == (keepGoing && bubbleErrorInfo != null),"String_Node_Str",skyKeys,catastrophe,keepGoing,bubbleErrorInfo);
  EvaluationResult.Builder<T> result=EvaluationResult.builder();
  List<SkyKey> cycleRoots=new ArrayList<>();
  for (  SkyKey skyKey : skyKeys) {
    ValueWithMetadata valueWithMetadata=getValueMaybeFromError(skyKey,bubbleErrorInfo);
    if (valueWithMetadata == null) {
      if (bubbleErrorInfo == null) {
        cycleRoots.add(skyKey);
      }
      continue;
    }
    SkyValue value=valueWithMetadata.getValue();
    replayingNestedSetEventVisitor.visit(valueWithMetadata.getTransitiveEvents());
    ErrorInfo errorInfo=valueWithMetadata.getErrorInfo();
    Preconditions.checkState(value != null || errorInfo != null,skyKey);
    if (!keepGoing && errorInfo != null) {
      result.addError(skyKey,errorInfo);
      continue;
    }
    if (value == null) {
      result.addError(skyKey,errorInfo);
    }
 else {
      result.addResult(skyKey,value);
    }
  }
  if (!cycleRoots.isEmpty()) {
    Preconditions.checkState(visitor != null,skyKeys);
    checkForCycles(cycleRoots,result,visitor,keepGoing);
  }
  if (catastrophe) {
    ErrorInfo errorInfo=Preconditions.checkNotNull(Iterables.getOnlyElement(bubbleErrorInfo.values()).getErrorInfo(),"String_Node_Str",bubbleErrorInfo);
    Preconditions.checkState(errorInfo.isCatastrophic(),"String_Node_Str",bubbleErrorInfo);
    result.setCatastrophe(errorInfo.getException());
  }
  EvaluationResult<T> builtResult=result.build();
  Preconditions.checkState(bubbleErrorInfo == null || builtResult.hasError(),"String_Node_Str",bubbleErrorInfo,skyKeys,builtResult);
  return builtResult;
}