Ensure attribute name lengths are reasonable

Puts a sensible, but generous, bound on attribute name length in order to
prevent (most probably accidental) runaway name lengths. The expectation is
that no reasonable human is or should be typing out 128 char attribute
names. Instead anything getting to this length is likely machine generated,
and should be checked for accidental unbounded growth.

While this is technically a breaking change, it's expected that the allowance
is generous enough that it's a noop. Do note that the previous max was
MAX_INT or the JVM OOMing, whichever came first, which is something we clearly
shouldn't allow.

RELNOTES: A maximum attribute name length is 128 is enforced
PiperOrigin-RevId: 305086330
diff --git a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleClassFunctionsTest.java b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleClassFunctionsTest.java
index f653a64..fe1e6f6 100644
--- a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleClassFunctionsTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleClassFunctionsTest.java
@@ -18,6 +18,7 @@
 import static org.junit.Assert.assertThrows;
 
 import com.google.common.base.Joiner;
+import com.google.common.base.Strings;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Iterables;
@@ -236,6 +237,21 @@
   }
 
   @Test
+  public void testRuleClassTooLongAttributeName() throws Exception {
+    ev.setFailFast(false);
+
+    evalAndExport(
+        "def impl(ctx): return;",
+        "r = rule(impl, attrs = { '" + Strings.repeat("x", 150) + "': attr.int() })");
+
+    assertThat(ev.getEventCollector()).hasSize(1);
+    Event event = ev.getEventCollector().iterator().next();
+    assertThat(event.getKind()).isEqualTo(EventKind.ERROR);
+    assertThat(event.getMessage())
+        .matches("Attribute r\\.x{150}'s name is too long \\(150 > 128\\)");
+  }
+
+  @Test
   public void testDisableDeprecatedParams() throws Exception {
     setSkylarkSemanticsOptions("--incompatible_disable_deprecated_attr_params=true");