Applying the Events recipe failed with fatal error because field_date already existed

Created on 29 May 2025, 2 months ago

Problem/Motivation

I was building a sort of event system and had added field_date on a custom content type I created.

On a second thought, I decided to use the drupal_cms_events recipe for the functionality instead of continuing with my custom content type.

When I tried to apply the recipe I got the error,

TypeError: Drupal\Core\Recipe\ConfigConfigurator::recursiveSortByKey(): Argument #1 ($data) must be of type array, false given, called in /var/www/html/public_html/core/lib/Drupal/Core/Recipe/ConfigConfigurator.php on line 60 in Drupal\Core\Recipe\ConfigConfigurator::recursiveSortByKey() (line 77 of /var/www/html/public_html/core/lib/Drupal/Core/Recipe/ConfigConfigurator.php).

I wondered which configuration could be the problem so I tried deleting field_date field and after that I was able to apply the recipe.

I didn't try checking if other recipes that ships with Drupal CMS has this type of existing configuration or configuration mismatch issue.

Steps to reproduce

1. Create a field named field_date manually.

2. Apply the drupal_cms_events recipe.

3. See the fatal error.

πŸ› Bug report
Status

Active

Component

Track: Event

Created by

πŸ‡³πŸ‡¬Nigeria chike Nigeria

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

Comments & Activities

  • Issue created by @chike
  • πŸ‡ΊπŸ‡ΈUnited States thejimbirch Cape Cod, Massachusetts

    This is expected. The event recipe treats the field_date strictly. Meaning if there is a field_date in the system, then it HAS to look exactly the same as it does in the recipe, and if it doesn't, it should fail.

    Here is where that is in the recipe.

    https://git.drupalcode.org/project/drupal_cms/-/blob/1.x/recipes/drupal_...

  • πŸ‡¦πŸ‡ΊAustralia pameeela

    It makes perfect sense to me that this doesn't work, but this is going to be pretty common in a world of contrib recipes and site templates. So it's definitely worth capturing these cases and improving the experience.

    In this case, the error itself is not very helpful. So improving the error message to provide specific information about what config is causing the problem, and what you can do to get around it, might be a good first step? That would be a recipe feature I assume?

  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

    I agree with both Jim and Pam here; fields determine the structure of the database and conflicts/differences can cause data loss, so it is completely reasonable for the recipe to require a pre-existing field_date to be a strict match.

    Closing because this works as intended.

  • πŸ‡¦πŸ‡ΊAustralia pameeela

    @phenaproxima So should we create a new issue for better error handling?

  • πŸ‡ΊπŸ‡ΈUnited States thejimbirch Cape Cod, Massachusetts

    In my recipes, I remove the

    field_

    and replace it with sa_ (for saplings). There is a secret simple config called field_ui.settings where you can change it.

    I call it secret because it has no UI, you need to change it in the config and then import it.

  • πŸ‡ΊπŸ‡ΈUnited States thejimbirch Cape Cod, Massachusetts

    Created a follow up issue in the Recipes component of core.

  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

    @pameeela, there's not a lot we can do from here - the error comes from core.

  • πŸ‡¦πŸ‡ΊAustralia pameeela

    Thanks, yes I assumed that the fix would be in core :) Just didn't want this to get lost.

Production build 0.71.5 2024