Program: 110628
Project: 110628
Buggy source:
/** 
 * Interpret the command-line arguments.
 * @param options the command-line arguments in structured form
 */
private static ResolvedTargets<Target> getTargetsToBuild(Environment env,TargetPatternPhaseKey options,PathPackageLocator pkgPath) throws InterruptedException {
  List<TargetPatternKey> patternSkyKeys=new ArrayList<>();
  for (  TargetPatternSkyKeyOrException keyOrException : TargetPatternValue.keys(options.getTargetPatterns(),options.getBuildManualTests() ? FilteringPolicies.NO_FILTER : FilteringPolicies.FILTER_MANUAL,options.getOffset())) {
    try {
      patternSkyKeys.add(keyOrException.getSkyKey());
    }
 catch (    TargetParsingException e) {
      env.getListener().post(new ParsingFailedEvent(keyOrException.getOriginalPattern(),e.getMessage()));
    }
  }
  Map<SkyKey,ValueOrException<TargetParsingException>> resolvedPatterns=env.getValuesOrThrow(patternSkyKeys,TargetParsingException.class);
  if (env.valuesMissing()) {
    return null;
  }
  ResolvedTargets.Builder<Target> builder=ResolvedTargets.builder();
  for (  TargetPatternKey pattern : patternSkyKeys) {
    TargetPatternValue value;
    try {
      value=(TargetPatternValue)resolvedPatterns.get(pattern).get();
    }
 catch (    TargetParsingException e) {
      String rawPattern=pattern.getPattern();
      String errorMessage=e.getMessage();
      env.getListener().handle(Event.error("String_Node_Str" + rawPattern + "String_Node_Str"+ errorMessage));
      builder.setError();
      continue;
    }
    ResolvedTargets<Target> asTargets=TestSuiteExpansionFunction.labelsToTargets(env,value.getTargets().getTargets(),value.getTargets().hasError());
    if (pattern.isNegative()) {
      builder.filter(Predicates.not(Predicates.in(asTargets.getTargets())));
    }
 else {
      builder.merge(asTargets);
    }
  }
  ResolvedTargets<Target> result=builder.filter(TargetUtils.tagFilter(options.getBuildTargetFilter())).build();
  if (options.getCompileOneDependency()) {
    TargetProvider targetProvider=new EnvironmentBackedRecursivePackageProvider(env,pkgPath);
    try {
      return new CompileOneDependencyTransformer(targetProvider).transformCompileOneDependency(env.getListener(),result);
    }
 catch (    MissingDepException e) {
      return null;
    }
catch (    TargetParsingException e) {
      env.getListener().handle(Event.error(e.getMessage()));
      return ResolvedTargets.failed();
    }
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Interpret the command-line arguments.
 * @param options the command-line arguments in structured form
 */
private static ResolvedTargets<Target> getTargetsToBuild(Environment env,TargetPatternPhaseKey options,PathPackageLocator pkgPath) throws InterruptedException {
  List<TargetPatternKey> patternSkyKeys=new ArrayList<>();
  ResolvedTargets.Builder<Target> builder=ResolvedTargets.builder();
  for (  TargetPatternSkyKeyOrException keyOrException : TargetPatternValue.keys(options.getTargetPatterns(),options.getBuildManualTests() ? FilteringPolicies.NO_FILTER : FilteringPolicies.FILTER_MANUAL,options.getOffset())) {
    try {
      patternSkyKeys.add(keyOrException.getSkyKey());
    }
 catch (    TargetParsingException e) {
      env.getListener().post(new ParsingFailedEvent(keyOrException.getOriginalPattern(),e.getMessage()));
      try {
        env.getValueOrThrow(TargetPatternErrorFunction.key(e.getMessage()),TargetParsingException.class);
      }
 catch (      TargetParsingException ignore) {
      }
      env.getListener().handle(Event.error("String_Node_Str" + keyOrException.getOriginalPattern() + "String_Node_Str"+ e.getMessage()));
      builder.setError();
    }
  }
  Map<SkyKey,ValueOrException<TargetParsingException>> resolvedPatterns=env.getValuesOrThrow(patternSkyKeys,TargetParsingException.class);
  if (env.valuesMissing()) {
    return null;
  }
  for (  TargetPatternKey pattern : patternSkyKeys) {
    TargetPatternValue value;
    try {
      value=(TargetPatternValue)resolvedPatterns.get(pattern).get();
    }
 catch (    TargetParsingException e) {
      String rawPattern=pattern.getPattern();
      String errorMessage=e.getMessage();
      env.getListener().handle(Event.error("String_Node_Str" + rawPattern + "String_Node_Str"+ errorMessage));
      builder.setError();
      continue;
    }
    ResolvedTargets<Target> asTargets=TestSuiteExpansionFunction.labelsToTargets(env,value.getTargets().getTargets(),value.getTargets().hasError());
    if (pattern.isNegative()) {
      builder.filter(Predicates.not(Predicates.in(asTargets.getTargets())));
    }
 else {
      builder.merge(asTargets);
    }
  }
  ResolvedTargets<Target> result=builder.filter(TargetUtils.tagFilter(options.getBuildTargetFilter())).build();
  if (options.getCompileOneDependency()) {
    TargetProvider targetProvider=new EnvironmentBackedRecursivePackageProvider(env,pkgPath);
    try {
      return new CompileOneDependencyTransformer(targetProvider).transformCompileOneDependency(env.getListener(),result);
    }
 catch (    MissingDepException e) {
      return null;
    }
catch (    TargetParsingException e) {
      try {
        env.getValueOrThrow(TargetPatternErrorFunction.key(e.getMessage()),TargetParsingException.class);
      }
 catch (      TargetParsingException ignore) {
      }
      env.getListener().handle(Event.error(e.getMessage()));
      return ResolvedTargets.failed();
    }
  }
  return result;
}