Recipe inputs fail schema validation

Created on 19 May 2025, 18 days ago

Problem/Motivation

History: Since last summer, it's been possible to write a recipe with "inputs," so the user can specify values at install time. This information gets added to the recipe.yml file. Documentation is hiding in a markdown file: https://git.drupalcode.org/project/distributions_recipes/-/blob/1.0.x/do...

Problem: The yaml schema is not aligned with with the documentation. When I add the `default` entries in the yaml file, I get an error:

Error: Unknown named parameter $default in /var/www/html/web/core/lib/Drupal/Core/Recipe/ConsoleInputCollector.php on line 105 #0 /var/www/html/web/core/lib/Drupal/Core/Recipe/InputConfigurator.php(154): Drupal\Core\Recipe\ConsoleInputCollector->collectValue()

However, when I remove the parameter, I get a different error:

Validation errors were found in ../recipes/ai-chatbot/recipe.yml:
- [input][pinecone_api_key][default][source]: This field is missing.
- [input][pinecone_api_key][default]: The '' key is required.

Steps to reproduce

  1. Start a new recipe in your project root: /recipes
  2. Add the basic required keys: name, description, type
  3. Optional: add the install block
  4. Required: add the input block, eg.:
    input:
      pinecone_api_key:
        data_type: string
        description: 'Pinecone API Key'
        form:
          '#type': password
          '#title': 'Pinecone API Key'
        prompt:
          method: askHidden
          arguments:
            question: 'Pinecone API Key'
        default:
          source: value
          value: ''

Proposed resolution

Update the schema so it validates the input block correctly

πŸ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States koppie

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @koppie
  • πŸ‡ΊπŸ‡ΈUnited States koppie

    Update: I think the problem may be caused specifically by my use of the askHidden method! Per Symfony documentation:

    It's very similar to the ask() method but the user's input will be hidden and it cannot define a default value. Use it when asking for sensitive information ...

    OK - so, ask is different from askHidden... so I guess the answer is to modify the schema specifically for askHidden.

  • πŸ‡ΊπŸ‡ΈUnited States koppie

    Update 2: Rather than update the schema, all we need is to modify the logic in the ConsoleInputCollector class.

    Before

        $arguments += [
          'default' => $default_value,
        ];
    

    After

        if ($method !== 'askHidden') {
          $arguments += [
            'default' => $default_value,
          ];
        }
    

    I tested it locally and it worked:

    I'm going to open up an MR (unless someone stops me)!

  • πŸ‡ΊπŸ‡ΈUnited States koppie

    Update 3: Never mind, I was looking in the wrong place! For the record: this project is for documentation (which does not need to be changed in this case). In fact, the issue has already been fixed in Drupal core: πŸ› askHidden prompt fails with "Unknown named parameter $default" Active

    Closing this ticket as "duplicate."

Production build 0.71.5 2024