From dee8d88336b717ba6e9fa8aa543dda76c83f008d Mon Sep 17 00:00:00 2001
From: Dave Long <dave@longwaveconsulting.com>
Date: Tue, 15 Oct 2024 10:42:12 +0100
Subject: [PATCH] Issue #3480180 by alexpott: Recipe validation error in 10.4.x

---
 core/lib/Drupal/Core/Recipe/Recipe.php        |  8 ++---
 .../Core/Recipe/RecipeValidationTest.php      | 29 ++++++++-----------
 2 files changed, 16 insertions(+), 21 deletions(-)

diff --git a/core/lib/Drupal/Core/Recipe/Recipe.php b/core/lib/Drupal/Core/Recipe/Recipe.php
index c9f5f055932c..5e0d55b2e13f 100644
--- a/core/lib/Drupal/Core/Recipe/Recipe.php
+++ b/core/lib/Drupal/Core/Recipe/Recipe.php
@@ -180,7 +180,7 @@ private static function parse(string $file): array {
         ]),
       ]),
       'input' => new Optional([
-        new Type('associative_array'),
+        new Type('array'),
         new All([
           new Collection(
             fields: [
@@ -192,7 +192,7 @@ private static function parse(string $file): array {
               // There can be an optional set of constraints, which is an
               // associative array of arrays, as in config schema.
               'constraints' => new Optional([
-                new Type('associative_array'),
+                new Type('array'),
               ]),
               'data_type' => [
                 // The data type must be known to the typed data system.
@@ -211,7 +211,7 @@ private static function parse(string $file): array {
                     new Choice(['ask', 'askHidden', 'confirm', 'choice']),
                   ],
                   'arguments' => new Optional([
-                    new Type('associative_array'),
+                    new Type('array'),
                   ]),
                 ]),
               ]),
@@ -224,7 +224,7 @@ private static function parse(string $file): array {
                   'value' => new Optional(),
                   'config' => new Optional([
                     new Sequentially([
-                      new Type('list'),
+                      new Type('array'),
                       new Count(2),
                       new All([
                         new Type('string'),
diff --git a/core/tests/Drupal/KernelTests/Core/Recipe/RecipeValidationTest.php b/core/tests/Drupal/KernelTests/Core/Recipe/RecipeValidationTest.php
index 55c140f2b87e..fe736e90062a 100644
--- a/core/tests/Drupal/KernelTests/Core/Recipe/RecipeValidationTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Recipe/RecipeValidationTest.php
@@ -351,15 +351,13 @@ public static function providerRecipeValidation(): iterable {
     yield 'input definitions are an indexed array' => [
       <<<YAML
 name: Bad input definitions
-input:
-  - data_type: string
-    description: A valid enough input, but in an indexed array.
-    default:
-      source: value
-      value: Here be dragons
+input: false
 YAML,
       [
-        '[input]' => ['This value should be of type associative_array.'],
+        '[input]' => [
+          'This value should be of type array.',
+          'This value should be of type iterable.',
+        ],
       ],
     ];
     yield 'input data type is missing' => [
@@ -413,14 +411,13 @@ public static function providerRecipeValidation(): iterable {
   foo:
     data_type: string
     description: 'Constraints need to be associative'
-    constraints:
-      - Type: string
+    constraints: false
     default:
       source: value
       value: Here be dragons
 YAML,
       [
-        '[input][foo][constraints]' => ['This value should be of type associative_array.'],
+        '[input][foo][constraints]' => ['This value should be of type array.'],
       ],
     ];
     yield 'input data type is unknown' => [
@@ -499,13 +496,13 @@ public static function providerRecipeValidation(): iterable {
     description: 'Prompt arguments must be associative'
     prompt:
       method: ask
-      arguments: [1, 2]
+      arguments: false
     default:
       source: value
       value: Here be dragons
 YAML,
       [
-        '[input][foo][prompt][arguments]' => ['This value should be of type associative_array.'],
+        '[input][foo][prompt][arguments]' => ['This value should be of type array.'],
       ],
     ];
     yield 'input definition without default value' => [
@@ -552,7 +549,7 @@ public static function providerRecipeValidation(): iterable {
       config: 'system.site:mail'
 YAML,
       [
-        '[input][foo][default][config]' => ['This value should be of type list.'],
+        '[input][foo][default][config]' => ['This value should be of type array.'],
       ],
     ];
     yield 'default value from config has too few values' => [
@@ -583,12 +580,10 @@ public static function providerRecipeValidation(): iterable {
       method: ask
     default:
       source: config
-      config:
-        name: system.site
-        key: mail
+      config: false
 YAML,
       [
-        '[input][foo][default][config]' => ['This value should be of type list.'],
+        '[input][foo][default][config]' => ['This value should be of type array.'],
       ],
     ];
     yield 'default value from config has non-string values' => [
-- 
GitLab