field_cron error on non-existent field

Created on 13 May 2025, 17 days ago

Problem/Motivation

I'm not sure if this is an issue with entity_reference or field...

We recently uninstalled a module that contained an custom entity. There were nodes that had entity_reference fields. We removed the reference fields but I'm still getting an error on the field_cron run

Drupal\Core\Field\FieldException: Field 'field_vt_recipients' on entity type 'monument' references a target entity type 'medal' which does not exist. in Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem::schema() (line 172 of /code/web/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php).

I've checked my config files and there's no medal reference or field_vt_recipients left. is there another place I can look to clear this error?

We're currently on v 10.4.6

💬 Support request
Status

Active

Version

10.4

Component

field system

Created by

🇺🇸United States rosemarystanley

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

Comments & Activities

  • Issue created by @rosemarystanley
  • 🇳🇿New Zealand quietone

    Just stopping by to add that the Drupal Core issue queue is not the ideal place for support requests. The 'support request' option is there for filing support issues for contributed modules and themes. There are several support options listed on our Support page . This is 'Get Support' at the top of Drupal.org. There is also information about Drupal Slack , at 'Get Support -> Drupal Slack' also at the top of Drupal.org. You may get better replies in one of those places.

  • 🇮🇳India Ishani Patel

    Hello @rosemaryreilman,
    I've some solution regarding this error.
    Please check the details below.

    1. Check Field Configuration in Active Config
    - Using this command: drush config:grep field_vt_recipients
    => If they still exist, remove them:
    - drush config:delete field.field.monument.field_vt_recipients
    - drush config:delete field.storage.monument.field_vt_recipients

    2. Also, you can check for Field Definitions in the Database:
    - Using query like this: SELECT * FROM config WHERE name LIKE '%field_vt_recipients%';

    Hope this solution is helpful for you.
    Thank you!

  • 1) drush config:delete field.storage.monument.field_vt_recipients

    //You can check it exists first using:
    2) drush config:get field.storage.monument.field_vt_recipients

    // Run SQL query to check for leftover field configs:
    3) SELECT * FROM config WHERE name LIKE '%field_vt_recipients%';

    //Or check manually in the Drupal UI
    Admin UI → Configuration → Development → Configuration synchronization → Single Import/Export → Find field.field.monument.field_vt_recipients

    //If you find it, delete it:

    drush config:delete field.field.monument.field_vt_recipients

    //Clear any references to the deleted entity type (medal)
    grep -r "medal" config/

    //Also, in the database:
    SELECT * FROM config WHERE data LIKE '%medal%';

    // Clean those configs if needed:
    drush config:delete core.entity_view_display.monument.default
    drush config:delete core.entity_form_display.monument.default

    //Drupal Rebuild
    drush cr
    drush entity:updates

  • 🇺🇸United States rosemarystanley

    Thanks everyone.
    @quietone thank you I'll try the other support methods as well.
    @ishani patel I tried all of your suggestions and nothing came up.
    @tushar5211 Thank you! I've tried all of your suggestions as well. (The drush entity:updates my install didn't recognize the command. I'm on Drush 13.6)

    I did some more digging. The old field still has field_deleted_data_*** tables. I tried outputting devel info and found the Field Config storage somehow still fields the field. I tried to load the field_config_storage entity manually (to then try and delete it) but it returns null. When I try and delete a field via the UI i get the same field exception and if I devel dump the info the config loads as if it exists. So odd.

  • Hello @rosemaryreilman Thanks for the update.
    Please try this as well using the custom module

    1. Check Config Entities Manually
    drush config:grep field_vt_recipients

    Also check:
    drush config:export --single "field.field.monument.field_vt_recipients"
    drush config:export --single "field.storage.monument.field_vt_recipients"

    2. Check and Delete Field Config Entities Programmatically
    If config exists but is partially broken, use this in a custom .module file or Drush command:
    $field_config = \Drupal\field\Entity\FieldConfig::load('monument.field_vt_recipients');
    if ($field_config) {
    $field_config->delete();
    }

    $field_storage = \Drupal\field\Entity\FieldStorageConfig::load('monument.field_vt_recipients');
    if ($field_storage) {
    $field_storage->delete();
    }

    3. Remove Field Data Tables Manually
    DROP TABLE IF EXISTS field_data_field_vt_recipients;
    DROP TABLE IF EXISTS field_revision_field_vt_recipients;
    DROP TABLE IF EXISTS field_deleted_data_field_vt_recipients;
    DROP TABLE IF EXISTS field_deleted_revision_field_vt_recipients;

    4. Clear All Caches and Rebuild Entity Definitions
    drush cache:rebuild
    drush entity:definition:rebuild

Production build 0.71.5 2024