**Build scan:**
https://gradle-enterprise.elastic.co/s/e4aqcdcvcf7yi/tests/:server:test/org.elasticsearch.BuildTests/testSerialization
**Reproduction line:**
```
./gradlew ':server:test' --tests "org.elasticsearch.BuildTests.testSerialization" -Dtests.seed=F05323488CF5212 -Dtests.locale=hi -Dtests.timezone=Pacific/Marquesas -Druntime.java=21
```

**Applicable branches:**
main

**Reproduces locally?:**
Yes

**Failure history:**
https://gradle-enterprise.elastic.co/scans/tests?tests.container=org.elasticsearch.BuildTests&tests.test=testSerialization
**Failure excerpt:**
```
java.lang.NullPointerException: Cannot invoke "String.length()" because "s" is null

  at __randomizedtesting.SeedInfo.seed([F05323488CF5212:5BDD537CAF9D6F8E]:0)
  at org.elasticsearch.test.BuildUtils.randomStringExcept(BuildUtils.java:103)
  at org.elasticsearch.test.BuildUtils.mutateBuild(BuildUtils.java:93)
  at org.elasticsearch.BuildTests.lambda$testSerialization$1(BuildTests.java:69)
  at org.elasticsearch.test.EqualsHashCodeTestUtils.checkEqualsAndHashCode(EqualsHashCodeTestUtils.java:93)
  at org.elasticsearch.test.EqualsHashCodeTestUtils.checkEqualsAndHashCode(EqualsHashCodeTestUtils.java:63)
  at org.elasticsearch.BuildTests.testSerialization(BuildTests.java:65)
  at jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
  at java.lang.reflect.Method.invoke(Method.java:580)
  at com.carrotsearch.randomizedtesting.RandomizedRunner.invoke(RandomizedRunner.java:1758)
  at com.carrotsearch.randomizedtesting.RandomizedRunner$8.evaluate(RandomizedRunner.java:946)
  at com.carrotsearch.randomizedtesting.RandomizedRunner$9.evaluate(RandomizedRunner.java:982)
  at com.carrotsearch.randomizedtesting.RandomizedRunner$10.evaluate(RandomizedRunner.java:996)
  at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
  at org.apache.lucene.tests.util.TestRuleSetupTeardownChained$1.evaluate(TestRuleSetupTeardownChained.java:48)
  at org.apache.lucene.tests.util.AbstractBeforeAfterRule$1.evaluate(AbstractBeforeAfterRule.java:43)
  at org.apache.lucene.tests.util.TestRuleThreadAndTestName$1.evaluate(TestRuleThreadAndTestName.java:45)
  at org.apache.lucene.tests.util.TestRuleIgnoreAfterMaxFailures$1.evaluate(TestRuleIgnoreAfterMaxFailures.java:60)
  at org.apache.lucene.tests.util.TestRuleMarkFailure$1.evaluate(TestRuleMarkFailure.java:44)
  at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
  at com.carrotsearch.randomizedtesting.ThreadLeakControl$StatementRunner.run(ThreadLeakControl.java:390)
  at com.carrotsearch.randomizedtesting.ThreadLeakControl.forkTimeoutingTask(ThreadLeakControl.java:843)
  at com.carrotsearch.randomizedtesting.ThreadLeakControl$3.evaluate(ThreadLeakControl.java:490)
  at com.carrotsearch.randomizedtesting.RandomizedRunner.runSingleTest(RandomizedRunner.java:955)
  at com.carrotsearch.randomizedtesting.RandomizedRunner$5.evaluate(RandomizedRunner.java:840)
  at com.carrotsearch.randomizedtesting.RandomizedRunner$6.evaluate(RandomizedRunner.java:891)
  at com.carrotsearch.randomizedtesting.RandomizedRunner$7.evaluate(RandomizedRunner.java:902)
  at org.apache.lucene.tests.util.AbstractBeforeAfterRule$1.evaluate(AbstractBeforeAfterRule.java:43)
  at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
  at org.apache.lucene.tests.util.TestRuleStoreClassName$1.evaluate(TestRuleStoreClassName.java:38)
  at com.carrotsearch.randomizedtesting.rules.NoShadowingOrOverridesOnMethodsRule$1.evaluate(NoShadowingOrOverridesOnMethodsRule.java:40)
  at com.carrotsearch.randomizedtesting.rules.NoShadowingOrOverridesOnMethodsRule$1.evaluate(NoShadowingOrOverridesOnMethodsRule.java:40)
  at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
  at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
  at org.apache.lucene.tests.util.TestRuleAssertionsRequired$1.evaluate(TestRuleAssertionsRequired.java:53)
  at org.apache.lucene.tests.util.AbstractBeforeAfterRule$1.evaluate(AbstractBeforeAfterRule.java:43)
  at org.apache.lucene.tests.util.TestRuleMarkFailure$1.evaluate(TestRuleMarkFailure.java:44)
  at org.apache.lucene.tests.util.TestRuleIgnoreAfterMaxFailures$1.evaluate(TestRuleIgnoreAfterMaxFailures.java:60)
  at org.apache.lucene.tests.util.TestRuleIgnoreTestSuites$1.evaluate(TestRuleIgnoreTestSuites.java:47)
  at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
  at com.carrotsearch.randomizedtesting.ThreadLeakControl$StatementRunner.run(ThreadLeakControl.java:390)
  at com.carrotsearch.randomizedtesting.ThreadLeakControl.lambda$forkTimeoutingTask$0(ThreadLeakControl.java:850)
  at java.lang.Thread.run(Thread.java:1583)

```
test/framework/src/main/java/org/elasticsearch/test/BuildUtils.java
*
     * @param existing A Build instance which will be copied
     * @param extraArgs A map of arguments to the Build constructor which will override values in the {@code existing} instance
     * @return A new Build instance
     */
    public static Build newBuild(Build existing, Map<String, Object> extraArgs) {
        var argsOverrides = new HashMap<>(extraArgs);
        RecordComponent[] argsComponents = Build.class.getRecordComponents();
        try {
            Object[] args = new Object[argsComponents.length];
            int i = 0;
            for (var argComponent : argsComponents) {
                Object value = argsOverrides.remove(argComponent.getName());
                if (value == null) {
                    value = argComponent.getAccessor().invoke(existing);
                }
                args[i++] = value;
            }
            if (argsOverrides.isEmpty() == false) {
                throw new AssertionError("Unknown Build arguments: " + argsOverrides.keySet());
            }
            return (Build) buildCtor.invokeWithArguments(args);
        } catch (Throwable t) {
            throw new AssertionError("Failed to create test Build instance", t);
        }
    }
    /**
     * Creates a random mutation of the given Build instance.
     *
     * The existing build instance is copied with a single field randomly changed. The value for the field is randomized.