**Build scan:**
https://gradle-enterprise.elastic.co/s/fbyzsxp52ifio/tests/:x-pack:plugin:transform:qa:multi-node-tests:javaRestTest/org.elasticsearch.xpack.transform.integration.TransformInsufficientPermissionsIT/testTransformPermissionsDeferUnattendedNoDest

**Reproduction line:**
```
./gradlew ':x-pack:plugin:transform:qa:multi-node-tests:javaRestTest' --tests "org.elasticsearch.xpack.transform.integration.TransformInsufficientPermissionsIT.testTransformPermissionsDeferUnattendedNoDest" -Dtests.seed=7D1146D3FAF85278 -Dtests.locale=is-IS -Dtests.timezone=America/Cambridge_Bay -Druntime.java=20
```

**Applicable branches:**
main

**Reproduces locally?:**
Yes

**Failure history:**
https://gradle-enterprise.elastic.co/scans/tests?tests.container=org.elasticsearch.xpack.transform.integration.TransformInsufficientPermissionsIT&tests.test=testTransformPermissionsDeferUnattendedNoDest

**Failure excerpt:**
```
java.lang.AssertionError: Stats were: {checkpointing={next={checkpoint=1, checkpoint_progress={docs_processed=0, docs_indexed=0}, timestamp_millis=1682380201153, time_upper_bound_millis=1682380200153}, last={checkpoint=0}}, node={transport_address=127.0.0.1:45399, name=javaRestTest-2, attributes={}, id=fX_1MyFnQyiDNW6ox-2IMQ, ephemeral_id=sFd185cYSjmAUQOgpquxGw}, stats={pages_processed=3, index_time_in_ms=0, documents_deleted=0, search_failures=0, index_failures=0, search_total=3, processing_total=3, delete_time_in_ms=0, documents_indexed=0, trigger_count=3, documents_processed=0, search_time_in_ms=26, index_total=0, exponential_avg_checkpoint_duration_ms=0.0, exponential_avg_documents_processed=0.0, processing_time_in_ms=0, exponential_avg_documents_indexed=0.0}, health={issues=[{issue=Privileges check failed, count=1, details=Cannot create transform [transform-permissions-defer-unattended] because user john_junior lacks the required permissions [transform-permissions-defer-unattended-dest:[create_index, index, read], transform-permissions-defer-unattended-index:[read, view_index_metadata]], type=privileges_check_failed}, {issue=Transform indexer failed, first_occurrence=1682380191072, count=3, details=org.elasticsearch.index.IndexNotFoundException: no such index [transform-permissions-defer-unattended-dest], type=transform_indexer_failed}], status=red}, id=transform-permissions-defer-unattended, state=started}
Expected: a collection with size <1>
     but: collection size was <2>

  at __randomizedtesting.SeedInfo.seed([7D1146D3FAF85278:D80B348FB95AC769]:0)
  at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:18)
  at org.junit.Assert.assertThat(Assert.java:956)
  at org.elasticsearch.xpack.transform.integration.TransformInsufficientPermissionsIT.assertRed(TransformInsufficientPermissionsIT.java:585)
  at org.elasticsearch.xpack.transform.integration.TransformInsufficientPermissionsIT.lambda$testTransformPermissionsDeferUnattendedNoDest$7(TransformInsufficientPermissionsIT.java:425)
  at org.elasticsearch.test.ESTestCase.assertBusy(ESTestCase.java:1158)
  at org.elasticsearch.xpack.transform.integration.TransformInsufficientPermissionsIT.testTransformPermissionsDeferUnattendedNoDest(TransformInsufficientPermissionsIT.java:425)
  at jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
  at java.lang.reflect.Method.invoke(Method.java:578)
  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:1623)

```
x-pack/plugin/transform/qa/multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/transform/integration/TransformInsufficientPermissionsIT.java
* unattended       = false
     */
    public void testNoTransformAdminRoleDeferNoUnattended() throws Exception {
        testNoTransformAdminRole(true, false);
    }
    /**
     * defer_validation = true
     * unattended       = true
     */
    public void testNoTransformAdminRoleDeferUnattended() throws Exception {
        testNoTransformAdminRole(true, true);
    }
    private void testNoTransformAdminRole(boolean deferValidation, boolean unattended) throws Exception {
        Users user = randomFrom(Users.SOURCE_AND_DEST_INDEX_ACCESS_ONLY, Users.TRANSFORM_USER_BUT_NOT_ADMIN);
        String transformId = "transform-permissions-no-transform-role";
        String sourceIndexName = transformId + "-index";
        String destIndexName = transformId + "-dest";
        createReviewsIndex(sourceIndexName, 10, NUM_USERS, TransformIT::getUserIdForRow, TransformIT::getDateStringForRow);
        TransformConfig config = createConfig(transformId, sourceIndexName, destIndexName, null, unattended);
        ResponseException e = expectThrows(
            ResponseException.class,
            () -> putTransform(
                transformId,
                Strings.toString(config),
                RequestOptions.DEFAULT.toBuilder()
                    .addHeader(AUTH_KEY, user.header)
                    .addParameter("defer_validation", String.valueOf(deferValidation))
                    .build()
            )
        );