Unverified Commit 70e5d0d7 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3557156 by phenaproxima: The ? optional syntax for config actions breaks recipe validation

(cherry picked from commit 556ddedc)
parent de1a892e
Loading
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -404,6 +404,13 @@ private static function validateRecipeExists(string $name, ExecutionContextInter
   */
  private static function validateConfigActions(mixed $value, ExecutionContextInterface $context, string $include_path): void {
    $config_name = str_replace(['[config][actions]', '[', ']'], '', $context->getPropertyPath());
    // If this set of config actions is optional, we don't need to validate that
    // it targets config belonging to a known extension -- the whole point of
    // optional config actions is that the targeted entity (or the extension
    // that provides it) might not exist, and that's okay.
    if (str_starts_with($config_name, '?')) {
      return;
    }
    [$config_provider] = explode('.', $config_name);
    if ($config_provider === 'core') {
      return;
+23 −0
Original line number Diff line number Diff line
@@ -353,6 +353,29 @@ public static function providerRecipeValidation(): iterable {
        ],
      ],
    ];
    yield 'config action targets an unknown extension' => [
      <<<YAML
name: Config action targets unknown extension
config:
  actions:
    node.settings:
      simpleConfigUpdate:
        use_admin_theme: true
YAML,
      [
        '[config][actions][node.settings]' => ['Config actions cannot be applied to node.settings because the node extension is not installed, and is not installed by this recipe or any of the recipes it depends on.'],
      ],
    ];
    yield 'optional config action targets an unknown extension' => [
      <<<YAML
name: Optional config action targets unknown extension
config:
  actions:
    ?node.type.test:
      setDescription: 'Hello there'
YAML,
      NULL,
    ];
    yield 'input definitions are an indexed array' => [
      <<<YAML
name: Bad input definitions