Problem/Motivation
Right now, recipes have no way to check ahead of time if they will be able to apply to the current site. They just sally forth and potentially hit a scary exception, which may or may not be helpful.
Proposed resolution
Drupal already has a mechanism for checking preconditions: condition plugins!
Recipes should leverage these by letting them be configured declaratively in recipe.yml. For example:
preconditions:
configValueIs:
- 'system.theme:default': olivero
summary: 'The front-end theme must be Olivero.'
- 'system.site:mail': 'dukat@terok.nor'
negate: true
summary: 'Emails from Drupal cannot be coming from Gul Dukat.'
Each set of conditions is handled by a particular plugin (configValueIs, in this case). Each plugin can accept multiple conditions, and each of those conditions may or may not be negated. Each may also be summarized in a human-friendly way so that the recipe can provide useful feedback if the condition doesn't check out.
The one rule is that all defined conditions must pass, or the recipe will refuse to apply. To use the technical jargon, all conditions are always logically ANDed together. There is no logical OR. If you want to do fancy-pants logic, you need a custom condition plugin.
This also opens the door to adding a --check (or similar) option to the recipe console command, so you can know if a recipe is compatible with your site. Project Browser could also benefit from this.
Remaining tasks
Make it so with tests.
API changes
Recipes will gain new declarative functionality, but condition plugins are a long-standing part of core so this is not going to introduce any API changes or additions.
Comments
Comment #2
phenaproximaComment #3
phenaproximaComment #4
phenaproximaComment #5
phenaproximaComment #6
thejimbirch commentedLove this!
Comment #7
b_sharpe commentedIn speaking with @phenaproxima it was determined this might not be entirely the correct approach here and likely needs further discussion before proceeding, marking NW to prevent someone spending time on possibly incorrect implementation.
Comment #8
mohit_aghera commentedMe and @alexpott had a chat during the DrupalCon Barcelona code sprint.
This issue needs issue summary update.
Primarily we are looking for some system that provides the conform for the recipe.
Intention is to validate that the site already has existing features that the recipe is already providing.
This system should be able to validate that current system state has all the necessary configurations applied.
Comment #9
bsnodgrass commentedmoved to Drupal Core, per https://www.drupal.org/project/distributions_recipes/issues/3513044
Comment #10
sonfdComment #11
breidert commentedWe need something like this for Drupal AI as well.
Comment #12
thejimbirch commentedMarcus created #3525303: Create Plugin Action for Recipes to check for installed default provider as an idea for this. It won't solve core's issue, but wanted to add it here so folks are aware/
Comment #13
marcus_johansson commentedI can add some perspective on what the AI module needs, since its probably a little bit different to most other use cases.
The AI module has at its core a normalization/abstraction layer of AI Providers like OpenAI or Anthropis. This is based on abstracted so called operation types with capabilities. These are usually built on input, output and similarity of feature set.
The most normal operation type is the Chat operation type where a model like gpt-4.1 or claude-3.7 from different providers works. Another could be text-to-image where Stable Diffusion or Dall-E exists.
On top of that we have capabilities, so for instance for an agentic system its vital that the Chat system handles so called tool calling.
To make sure that everyone that creates third party modules that interacts with the abstraction layer, we have made sure that when you install and setup a new provider, it can say that its the default provider/model for any combination of these operation types and capabilities. You also have a settings form where you can set or change this yourself.
At time of writing we have 20+ providers, where almost all of them has a unique use case for the right customer/consumer.
But for the third party app, it doesn't matter which provider is running in the background, it sends input and receives output in a normalized way.
This means two things for recipes where the AI module probably differs:
So we need a way to determine if an operation type/capability is set and the recipes should just have to verify this part and nothing else. That would be the most optimal way of working for us.
Comment #14
marcus_johansson commentedI can note that #3525303: Create Plugin Action for Recipes to check for installed default provider is a workaround for this, but the config action plugin system is obviously not where this logic belongs.
Comment #15
thejimbirch commentedAdding #3461946: Recipes have no way to tell if they're set up for success as related and a possible different approach.
Comment #16
fagoCurrently missing this feature as well. It seems like this has been a frequent request / missing part, so I'd say this is major for recipes.