Program: 110516
Project: 110516
Buggy source:
/** 
 * Returns a function-value implementing the build or workspace rule "ruleClass" (e.g. cc_library) in the specified package context.
 */
private static BuiltinFunction newRuleFunction(final RuleFactory ruleFactory,final String ruleClassName,final boolean allowOverride){
  return new BuiltinFunction(ruleClassName,FunctionSignature.KWARGS,BuiltinFunction.USE_AST_ENV){
    public Object invoke(    Map<String,Object> kwargs,    FuncallExpression ast,    Environment env) throws EvalException, InterruptedException {
      try {
        Package.Builder builder=PackageFactory.getContext(env,ast.getLocation()).pkgBuilder;
        if (!allowOverride && kwargs.containsKey("String_Node_Str") && builder.targets.containsKey(kwargs.get("String_Node_Str"))) {
          throw new EvalException(ast.getLocation(),"String_Node_Str" + "String_Node_Str" + kwargs.get("String_Node_Str") + "String_Node_Str");
        }
        if (env.getSemantics().experimentalEnableRepoMapping()) {
          if (kwargs.containsKey("String_Node_Str")) {
            if (!(kwargs.get("String_Node_Str") instanceof Map)) {
              throw new EvalException(ast.getLocation(),"String_Node_Str" + kwargs.get("String_Node_Str") + "String_Node_Str");
            }
            @SuppressWarnings("String_Node_Str") Map<String,String> map=(Map<String,String>)kwargs.get("String_Node_Str");
            String externalRepoName=(String)kwargs.get("String_Node_Str");
            for (            Map.Entry<String,String> e : map.entrySet()) {
              builder.addRepositoryMappingEntry(RepositoryName.createFromValidStrippedName(externalRepoName),RepositoryName.create((String)e.getKey()),RepositoryName.create((String)e.getValue()));
            }
          }
        }
        RuleClass ruleClass=ruleFactory.getRuleClass(ruleClassName);
        RuleClass bindRuleClass=ruleFactory.getRuleClass("String_Node_Str");
        Rule rule=WorkspaceFactoryHelper.createAndAddRepositoryRule(builder,ruleClass,bindRuleClass,getFinalKwargs(kwargs,env.getSemantics()),ast);
        if (!isLegalWorkspaceName(rule.getName())) {
          throw new EvalException(ast.getLocation(),rule + "String_Node_Str");
        }
      }
 catch (      RuleFactory.InvalidRuleException|Package.NameConflictException|LabelSyntaxException e) {
        throw new EvalException(ast.getLocation(),e.getMessage());
      }
      return NONE;
    }
  }
;
}

Fixed version (ground truth):
/** 
 * Returns a function-value implementing the build or workspace rule "ruleClass" (e.g. cc_library) in the specified package context.
 */
private static BuiltinFunction newRuleFunction(final RuleFactory ruleFactory,final String ruleClassName,final boolean allowOverride){
  return new BuiltinFunction(ruleClassName,FunctionSignature.KWARGS,BuiltinFunction.USE_AST_ENV){
    public Object invoke(    Map<String,Object> kwargs,    FuncallExpression ast,    Environment env) throws EvalException, InterruptedException {
      try {
        Package.Builder builder=PackageFactory.getContext(env,ast.getLocation()).pkgBuilder;
        if (!allowOverride && kwargs.containsKey("String_Node_Str") && builder.targets.containsKey(kwargs.get("String_Node_Str"))) {
          throw new EvalException(ast.getLocation(),"String_Node_Str" + "String_Node_Str" + kwargs.get("String_Node_Str") + "String_Node_Str");
        }
        String externalRepoName=(String)kwargs.get("String_Node_Str");
        if (!Strings.isNullOrEmpty(builder.pkg.getWorkspaceName())) {
          builder.addRepositoryMappingEntry(RepositoryName.createFromValidStrippedName(externalRepoName),RepositoryName.createFromValidStrippedName(builder.pkg.getWorkspaceName()),RepositoryName.MAIN);
        }
        if (env.getSemantics().experimentalEnableRepoMapping()) {
          if (kwargs.containsKey("String_Node_Str")) {
            if (!(kwargs.get("String_Node_Str") instanceof Map)) {
              throw new EvalException(ast.getLocation(),"String_Node_Str" + kwargs.get("String_Node_Str") + "String_Node_Str");
            }
            @SuppressWarnings("String_Node_Str") Map<String,String> map=(Map<String,String>)kwargs.get("String_Node_Str");
            for (            Map.Entry<String,String> e : map.entrySet()) {
              builder.addRepositoryMappingEntry(RepositoryName.createFromValidStrippedName(externalRepoName),RepositoryName.create((String)e.getKey()),RepositoryName.create((String)e.getValue()));
            }
          }
        }
        RuleClass ruleClass=ruleFactory.getRuleClass(ruleClassName);
        RuleClass bindRuleClass=ruleFactory.getRuleClass("String_Node_Str");
        Rule rule=WorkspaceFactoryHelper.createAndAddRepositoryRule(builder,ruleClass,bindRuleClass,getFinalKwargs(kwargs,env.getSemantics()),ast);
        if (!isLegalWorkspaceName(rule.getName())) {
          throw new EvalException(ast.getLocation(),rule + "String_Node_Str");
        }
      }
 catch (      RuleFactory.InvalidRuleException|Package.NameConflictException|LabelSyntaxException e) {
        throw new EvalException(ast.getLocation(),e.getMessage());
      }
      return NONE;
    }
  }
;
}