Field error when importing config after upgrading to 3.1.0

Created on 28 June 2023, over 1 year ago
Updated 2 August 2023, over 1 year ago

When I upgraded from 3.0.9 to 3.1.0, deploying the config changes threw this error when the deployment script executed drush cim -y command:

W:  [error]  Drupal\Core\Config\ConfigException: Errors occurred during import in Drush\Drupal\Commands\config\ConfigImportCommands->doImport() (line 346 of /app/vendor/drush/drush/src/Drupal/Commands/config/ConfigImportCommands.php). 
        W: 
        W: In ConfigImportCommands.php line 360:
        W:                                                                                
        W:   The import failed due to the following reasons:                              
        W:   Unexpected error during import with operation update for field.storage.opig  
        W:   no_answer.field_response: Saving the configuration entity with ID field.sto  
        W:   rage.opigno_answer.field_response generated an exception: 'Cannot chan  
        W:   ge the field type for an existing field storage. The field storage opigno_a  
        W:   nswer.field_response has the type string.'                              
🐛 Bug report
Status

Active

Version

3.1

Component

Code

Created by

🇪🇸Spain joe_carvajal Seville (Spain)

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

Comments & Activities

  • Issue created by @joe_carvajal
  • 🇪🇸Spain joe_carvajal Seville (Spain)
  • 🇬🇧United Kingdom niklp Nottingham

    To work around this, we simply deleted the field, which was empty for us.

    ** NB this might not apply as well to other users! **

  • 🇨🇭Switzerland berdir Switzerland

    the field is re-created in an update function, so I think that is pretty much expected, you need to re-export at least that part of the config after the update.

    There's another issue that it reports as a changed entity field definition, I think it's not property registered due to the way it's recreated, but I was able to resolve that by manually calling

    $field_storage_definition = \Drupal::service('entity_field.manager')->getFieldStorageDefinitions('opigno_answer')['field_response'];
    \Drupal::entityDefinitionUpdateManager()->updateFieldStorageDefinition($field_storage_definition);

Production build 0.71.5 2024