Drupal\Core\Field\FieldException: Attempted to create, modify or delete an instance of field with name field_icon on entity type node when the field storage does not exist. in Drupal\field\Entity\FieldConfig->getFieldStorageDefinition() (line 316 of core/

Created on 27 December 2024, about 1 month ago

Problem/Motivation

I am using Drupal 11. I installed the module using the command composer require 'drupal/iconify_field:^1.1', then tried creating a field of type icon and ever since my project is throwing this error:
Drupal\Core\Field\FieldException: Attempted to create, modify or delete an instance of field with name field_icon on entity type node when the field storage does not exist. in Drupal\field\Entity\FieldConfig->getFieldStorageDefinition() (line 316 of core/

I am not able to delete this module either.

Any help is appreciated.

🐛 Bug report
Status

Active

Version

1.1

Component

Code

Created by

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

Comments & Activities

  • Issue created by @ckfspl
  • 🇳🇱Netherlands Dobefu

    Hiya ckfspl!

    Thank you for submitting this issue! Let me check locally if I can reproduce this locally. I'll get back to you in this issue once I've checked.

  • 🇳🇱Netherlands Dobefu

    Hi ckfspl!

    I've tried to reproduce the issue locally, but unfortunately I cannot seem to get the same error. Could you maybe provide a list of modules that you are using in your site? I suspect that it might be an incompatibility of some sort, but I cannot be sure at this point in time.

  • Contributed modules:

    address
    ctools
    devel
    entity_reference_revisions
    field_group
    google_map_field
    iconify_field
    menu_bootstrap_icon
    office_hours
    paragraphs
    paragraphs_bundles
    pathauto
    solo_utilities
    token
    webicons
    Core modules
    announcements_feed
    automated_cron
    ban
    basic_auth
    big_pipe
    block
    block_content
    breakpoint
    ckeditor5
    comment
    config
    config_translation
    contact
    content_moderation
    content_translation
    contextual
    datetime
    datetime_range
    dblog
    dynamic_page_cache
    editor
    field
    field_layout
    field_ui
    file
    filter
    help
    history
    image
    inline_form_errors
    jsonapi
    language
    layout_builder
    layout_discovery
    link
    locale
    media
    media_library
    menu_link_content
    menu_ui
    migrate
    migrate_drupal
    migrate_drupal_ui
    mysql
    navigation
    node
    options
    page_cache
    path
    path_alias
    pgsql
    phpass
    responsive_image
    rest
    sdc
    search
    serialization
    settings_tray
    shortcut
    sqlite
    syslog
    system
    taxonomy
    telephone
    text
    toolbar
    update
    user
    views
    views_ui
    workflows
    workspaces

  • I have manually added field.storage.node.field_icon.yml file in web/core/profiles/standard/config/install but the error is still there.
    Contents of field.storage.node.field_icon.yml file:

    langcode: en
    status: true
    dependencies:
    module:
    - iconify_field
    - node
    id: node.field_icon
    field_name: field_icon
    entity_type: node
    type: iconify_field_icon
    settings: { }
    module: iconify_field
    locked: false
    cardinality: 1
    translatable: true
    indexes: { }
    persist_with_no_fields: false
    custom_storage: false

  • 🇳🇱Netherlands Dobefu

    Ah, I see. Thank you for the list of modules! That will be really help me debug this.

    I see that you've manually placed the field.storage.node.field_icon.yml in a config directory. You're definitely on the right track with that, but it will need to be in a slightly different directory. For default Drupal installations, it will often be `sites/default/sites/sync`. But this might also be in `config/sync`, depending on the installation.
    Once you have the file in there, you can run `drush cim` from the command line to import the configuration.

    If my solution listed above doesn't work, are you open to communicate on Slack or Discord? I'll be able to personally guide you through it that way.

  • Thank you for the response. I did the steps mentioned above and got the following error:

    In ConfigImportCommands.php line 291:

    The import failed due to the following reasons:
    Unexpected error during import with operation create for field.storage.node.field_icon: Exception thrown while performing a schema update. SQLSTATE[42000]: Syntax error or access violation: 1101 BLOB, TEXT, GEOMETRY or JSO
    N column 'field_icon_value' can't have a default value: CREATE TABLE "node__field_icon" (
    "bundle" VARCHAR(128) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL DEFAULT '' COMMENT 'The field instance bundle to which this row belongs, used when deleting a field instance',
    "deleted" TINYINT NOT NULL DEFAULT 0 COMMENT 'A boolean indicating whether this data item has been deleted',
    "entity_id" INT unsigned NOT NULL COMMENT 'The entity id this data is attached to',
    "revision_id" INT unsigned NOT NULL COMMENT 'The entity revision id this data is attached to',
    "langcode" VARCHAR(32) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL DEFAULT '' COMMENT 'The language code for this data item.',
    "delta" INT unsigned NOT NULL COMMENT 'The sequence number for this data item, used for multi-value fields',
    "field_icon_value" TEXT NOT NULL DEFAULT '',
    "field_icon_classes" VARCHAR(255) NULL DEFAULT '',
    "field_icon_decorative" TINYINT NULL DEFAULT 1,
    "field_icon_arialabel" TEXT NULL DEFAULT '',
    PRIMARY KEY ("entity_id", "deleted", "delta", "langcode"),
    INDEX "bundle" ("bundle"),
    INDEX "revision_id" ("revision_id")
    ) ENGINE = InnoDB DEFAULT CHARACTER SET utf8mb4 COMMENT 'Data storage for node field field_icon.'; Array
    (
    )

    I am open to connect on Discord as well.

  • 🇳🇱Netherlands Dobefu

    Ah, I see that you are using Postgres. I think that that might be why it's failing. I haven't tested the module with that just yet. Let me see if I can reproduce it in Postgres!

  • 🇳🇱Netherlands Dobefu

    Hmm, it works for me with Postgres as well. Though I may need to do some more testing. Could you please add me on Discord? My username is Dobefu (dobefu_61210). I don't have a lot of time today, unfortunately. But I'm available to help you tomorrow, if that works for you.

  • Sure, no problem.
    I am using MySQL version 8.0.33

    • dobefu committed 0ccf3125 on 1.x
      fix: Remove some default values on text fields, to resolve #3496280
      
  • 🇳🇱Netherlands Dobefu

    We have talked about this issue, and came to the conclusion that this issue only happens on MySQL databases. I have tried to debug it on MariaDB and Postgres before, which did not have this issue. A new release has now fixed the issue.

Production build 0.71.5 2024