Recipes have no way to tell if they're set up for success

Created on 17 July 2024, about 2 months ago

Problem/Motivation

Right now, recipes have no way to tell in advance if they will apply successfully. They just sally forth and throw an exception if something goes wrong. That's limiting, and potentially frustrating, and the resulting exceptions can be pretty opaque and unclear on what went wrong.

Proposed resolution

Recipes need some way to define preconditions. I propose we take advantage of core's condition plugin API for this, and add a section to recipe.yml called preconditions, which is an associative array where the keys are condition plugin IDs, and the values are indexed arrays, where each item of the array is a set of configuration for that plugin. All conditions must check out in order for the recipe to be applied.

For example:

preconditions:
  matchingEntityExists:
    - entity_type_id: field_config
       criteria:
         # Properties to pass to an entity query.
         type: image
         entity_type_id: node
         bundle: blog_post
    - entity_type_id: node_type
       criteria:
         name: Blog

Translated to English, this means the recipe requires two things:

  1. An image field on blog_post nodes.
  2. A node type whose human-readable name is "Blog".

Conditions have human-readable summaries, so this would open the door to much clearer error messages about why a recipe cannot be applied.

Feature request
Status

Active

Version

11.0 🔥

Component
recipe system 

Last updated less than a minute ago

Created by

🇺🇸United States phenaproxima Massachusetts

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

Comments & Activities

Production build 0.71.5 2024