Could not retrieve data definition for field

Created on 9 June 2021, over 3 years ago
Updated 19 September 2023, over 1 year ago

Problem/Motivation

Error message is shown while installing module:

[error]  Drupal\search_api\SearchApiException while adding Views handlers for field Content ยป Body on index Acquia Search Solr Index: Could not retrieve data definition for field 'Body' on index 'Acquia Search Solr Index'. in Drupal\search_api\Item\Field->getDataDefinition() (line 441 of /private/tmp/../docroot/modules/contrib/search_api/src/Item/Field.php). 
 [error]  Drupal\search_api\SearchApiException while computing Views data for index Acquia Search Solr Index: Could not retrieve data definition for field 'Body' on index 'Acquia Search Solr Index'. in Drupal\search_api\Item\Field->getDataDefinition() (line 441 of /private/tmp/../docroot/modules/contrib/search_api/src/Item/Field.php). 
๐Ÿ’ฌ Support request
Status

Fixed

Version

3.1

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia n4r3n Goa

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia renukakulkarni

    The issue is present in 3.1.4 version also.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom tomdearden

    Seeing this here, too on 3.1.4 - if I delete the config for the 'Body' field on Node entities before installing then the 'optional' config for the sample Search API index that this module seeks to install when enabled isn't created and this error doesn't appear - I don't use the 'standard' install profile's Body field so this isn't an issue in my application.

    I'm not sure that, in general, this module should be looking to create a Search API index anyway. I can see a use case for a server, perhaps (although this being installed automatically still feels wrong to me) but an index should surely be up to the user to configure?

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States mglaman WI, USA
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States mglaman WI, USA

    The index is already optional, I'm guessing it got installed and then the body field deleted?

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States mglaman WI, USA

    I tried to replicate this. I think I found a way that puts the site in this state. Both search_api.index.acquia_search_index and views.view.acquia_search are in config/optional. Both have config dependencies on field.storage.node.body. This is not the field config but its storage.

    On a Standard install I deleted the body field from Article and Basic Page. This deleted the field.config config but not the storage! Because storage is cleaned up at a later time when there are no field config instances.

    So in this gap the view and index installed. I'm going to see if I can trigger the storage clean up.

  • Status changed to Postponed: needs info almost 2 years ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States mglaman WI, USA

    Can someone explain how they're reaching here? I don't see this as a fault of this module but rather Drupal failing to handle config constraints. In my setup, Drupal did not purge the field storage. I think it is then kept around for the Index and View's dependency.

    Did you manually remove it and then import configuration, which Drupal then failed to validate and prevent an improper input? I don't see this as the case given the issue summary talks about install failing due to missing field storage config.

    I'm not sure that, in general, this module should be looking to create a Search API index anyway. I can see a use case for a server, perhaps (although this being installed automatically still feels wrong to me) but an index should surely be up to the user to configure?

    We are also discussing this as well.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States mglaman WI, USA

    Also, for the record: field.storage.node.body is created by Node with persist_with_no_fields: true which prevents it from being purged. That means the configuration had to be explicitly removed.

    I don't know how that could break installation on /admin/modules. The only way I could see this breaking is:

    • Acquia Search was installed
    • Site config exported with all dependencies
    • field.storage.node.body was manually deleted
    • The default Index and View for the index rely on field.storage.node.body, config import tries to install config and dependency has been removed out-of-band manually so Drupal breaks.

    I agree we can discuss if the index or view should be provided. But given the above scenario that is not a bug caused by the module.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom tomdearden

    Hi @mglaman - I think I found the reverse to be true ie. _removing_ the config for `field.storage.node.body` was the thing that prevented the optional config being installed and thus resolved the issue with an exception being thrown on install.

    I'll see if I can go back over my project's commit history and construct a minimal set of actions to reproduce and will let you know.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom tomdearden

    OK - here's a sequence of actions that should produce this error in a minimally-configured install:

    Set up a Drupal 9 site on your favourite development platform (I used Lando to get a containerised server up and running quickly but don't think it matters):

    ```
    composer create-project drupal/recommended-project:^9.5
    composer require drush/drush
    drush site:install
    ```

    Then:

    - log in and navigate to the Content Types overview page at `/admin/structure/types`
    - remove both the existing entries
    - create your own ones if you like, so long as they don't use the 'Body' field

    At this point you should have an installation that will throw the exception above if you try and install the Acquia Search module eg.

    ```
    composer require drupal/acquia_search
    drush en acquia_search
    ```

    I get the error in the issue description reliably when doing this.

    Hope that's useful!

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States mglaman WI, USA

    Thanks. That's what I tried :/ but I'll try again. What version of Drupal core just to be sure? I'll try again tomorrow.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom tomdearden

    As of yesterday, the above installed Drupal 9.5.3, with acquia_search 3.1.5. Full output from composer show below:

    acquia/http-hmac-php                     6.0.0    An implementation of the HTTP HMAC Spec in PHP that integrates with popular libraries such as Symfony and Guzzle.
    asm89/stack-cors                         1.3.0    Cross-origin resource sharing library and stack middleware
    chi-teck/drupal-code-generator           2.6.2    Drupal code generator
    composer/installers                      v1.12.0  A multi-framework Composer library installer
    composer/semver                          3.3.2    Semver library that offers utilities, version constraint parsing and validation.
    consolidation/annotated-command          4.7.1    Initialize Symfony Console commands from annotated command class methods.
    consolidation/config                     2.1.2    Provide configuration services for a commandline tool.
    consolidation/filter-via-dot-access-data 2.0.2    This project uses dflydev/dot-access-data to provide simple output filtering for applications built with annotated-co...
    consolidation/log                        2.1.1    Improved Psr-3 / Psr\Log logger based on Symfony Console components.
    consolidation/output-formatters          4.2.3    Format text by applying transformations provided by plug-in formatters.
    consolidation/robo                       4.0.2    Modern task runner
    consolidation/self-update                2.1.0    Provides a self:update command for Symfony Console applications.
    consolidation/site-alias                 4.0.0    Manage alias records for local and remote sites.
    consolidation/site-process               4.2.1    A thin wrapper around the Symfony Process Component that allows applications to use the Site Alias library to specify...
    dflydev/dot-access-data                  v3.0.2   Given a deep data structure, access data by dot notation.
    doctrine/annotations                     1.13.3   Docblock Annotations Parser
    doctrine/lexer                           1.2.3    PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.
    doctrine/reflection                      1.2.3    The Doctrine Reflection project is a simple library used by the various Doctrine projects which adds some additional ...
    drupal/acquia_connector                  4.0.3    Allows Drupal websites to connect with Acquia.
    drupal/acquia_search                     3.1.5    Provides integration between your Drupal site and Acquia's hosted search service.
    drupal/core                              9.5.3    Drupal is an open source content management platform powering millions of websites and applications.
    drupal/core-composer-scaffold            9.5.3    A flexible Composer project scaffold builder.
    drupal/core-project-message              9.5.3    Adds a message after Composer installation.
    drupal/core-recommended                  9.5.3    Core and its dependencies with known-compatible minor versions. Require this project INSTEAD OF drupal/core.
    drupal/search_api                        1.28.0   Provides a generic framework for modules offering search capabilities.
    drupal/search_api_solr                   4.2.10   Offers an implementation of the Search API that uses an Apache Solr server for indexing content.
    drush/drush                              11.5.1   Drush is a command line shell and scripting interface for Drupal, a veritable Swiss Army knife designed to make life ...
    egulias/email-validator                  3.2.5    A library for validating emails against several RFCs
    enlightn/security-checker                v1.10.0  A PHP dependency vulnerabilities scanner based on the Security Advisories Database.
    grasmash/expander                        2.0.3    Expands internal property references in PHP arrays file.
    guzzlehttp/guzzle                        6.5.8    Guzzle is a PHP HTTP client library
    guzzlehttp/promises                      1.5.2    Guzzle promises library
    guzzlehttp/psr7                          1.9.0    PSR-7 message implementation that also provides common utility methods
    http-interop/http-factory-guzzle         1.2.0    An HTTP Factory using Guzzle PSR7
    laminas/laminas-diactoros                2.14.0   PSR HTTP Message implementations
    laminas/laminas-escaper                  2.9.0    Securely and safely escape HTML, HTML attributes, JavaScript, CSS, and URLs
    laminas/laminas-feed                     2.17.0   provides functionality for consuming RSS and Atom feeds
    laminas/laminas-stdlib                   3.11.0   SPL extensions, array utilities, error handlers, and more
    league/container                         4.2.0    A fast and intuitive dependency injection container.
    maennchen/zipstream-php                  2.2.6    ZipStream is a library for dynamically streaming dynamic zip files from PHP without writing to the disk at all on the...
    masterminds/html5                        2.7.6    An HTML5 parser and serializer.
    myclabs/php-enum                         1.8.4    PHP Enum implementation
    nikic/php-parser                         v4.15.3  A PHP parser written in PHP
    pear/archive_tar                         1.4.14   Tar file management class with compression support (gzip, bzip2, lzma2)
    pear/console_getopt                      v1.4.3   More info available on: http://pear.php.net/package/Console_Getopt
    pear/pear-core-minimal                   v1.10.11 Minimal set of PEAR core files to be used as composer dependency
    pear/pear_exception                      v1.0.2   The PEAR Exception base class.
    psr/cache                                1.0.1    Common interface for caching libraries
    psr/container                            1.1.1    Common Container Interface (PHP FIG PSR-11)
    psr/event-dispatcher                     1.0.0    Standard interfaces for event handling.
    psr/http-client                          1.0.1    Common interface for HTTP clients
    psr/http-factory                         1.0.1    Common interfaces for PSR-7 HTTP message factories
    psr/http-message                         1.0.1    Common interface for HTTP messages
    psr/log                                  1.1.4    Common interface for logging libraries
    psy/psysh                                v0.11.12 An interactive shell for modern PHP.
    ralouphie/getallheaders                  3.0.3    A polyfill for getallheaders.
    solarium/solarium                        6.2.8    PHP Solr client
    stack/builder                            v1.0.6   Builder for stack middleware based on HttpKernelInterface.
    symfony-cmf/routing                      2.3.4    Extends the Symfony routing component for dynamic routes and chaining several routers
    symfony/console                          v4.4.49  Eases the creation of beautiful and testable command line interfaces
    symfony/debug                            v4.4.44  Provides tools to ease debugging PHP code
    symfony/dependency-injection             v4.4.49  Allows you to standardize and centralize the way objects are constructed in your application
    symfony/deprecation-contracts            v2.5.2   A generic function and convention to trigger deprecation notices
    symfony/error-handler                    v4.4.44  Provides tools to manage errors and ease debugging PHP code
    symfony/event-dispatcher                 v4.4.44  Provides tools that allow your application components to communicate with each other by dispatching events and listen...
    symfony/event-dispatcher-contracts       v1.1.13  Generic abstractions related to dispatching event
    symfony/filesystem                       v5.4.19  Provides basic utilities for the filesystem
    symfony/finder                           v5.4.19  Finds files and directories via an intuitive fluent interface
    symfony/http-client-contracts            v2.5.2   Generic abstractions related to HTTP clients
    symfony/http-foundation                  v4.4.49  Defines an object-oriented layer for the HTTP specification
    symfony/http-kernel                      v4.4.50  Provides a structured process for converting a Request into a Response
    symfony/mime                             v5.4.13  Allows manipulating MIME messages
    symfony/polyfill-ctype                   v1.27.0  Symfony polyfill for ctype functions
    symfony/polyfill-iconv                   v1.27.0  Symfony polyfill for the Iconv extension
    symfony/polyfill-intl-grapheme           v1.27.0  Symfony polyfill for intl's grapheme_* functions
    symfony/polyfill-intl-idn                v1.27.0  Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions
    symfony/polyfill-intl-normalizer         v1.27.0  Symfony polyfill for intl's Normalizer class and related functions
    symfony/polyfill-mbstring                v1.27.0  Symfony polyfill for the Mbstring extension
    symfony/polyfill-php72                   v1.27.0  Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions
    symfony/polyfill-php73                   v1.27.0  Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions
    symfony/polyfill-php80                   v1.27.0  Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions
    symfony/process                          v4.4.44  Executes commands in sub-processes
    symfony/psr-http-message-bridge          v2.1.4   PSR HTTP message bridge
    symfony/routing                          v4.4.44  Maps an HTTP request to a set of configuration variables
    symfony/serializer                       v4.4.47  Handles serializing and deserializing data structures, including object graphs, into array structures or other format...
    symfony/service-contracts                v2.5.2   Generic abstractions related to writing services
    symfony/string                           v5.4.19  Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified...
    symfony/translation                      v4.4.47  Provides tools to internationalize your application
    symfony/translation-contracts            v2.5.2   Generic abstractions related to translation
    symfony/validator                        v4.4.48  Provides tools to validate values
    symfony/var-dumper                       v5.4.19  Provides mechanisms for walking through any arbitrary PHP variable
    symfony/yaml                             v4.4.45  Loads and dumps YAML files
    twig/twig                                v2.15.4  Twig, the flexible, fast, and secure template language for PHP
    typo3/phar-stream-wrapper                v3.1.7   Interceptors for PHP's native phar:// stream handling
    webflo/drupal-finder                     1.2.2    Helper class to locate a Drupal installation from a given path.
    
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom tomdearden
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States mglaman WI, USA

    @tomdearden !! I appreciate your assistance with this information. I realized my environment was still on Drupal 10, not Drupal 9. Something weird is happening where the field storage is being immediately purged on your site even though it's configured not to be purged. Then on my side it is respected.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom tomdearden

    Hi @mglaman I'm not sure that can be the case - when I run

    drush cget field.storage.node.body
    

    I get

    uuid: 6f05f858-503c-450b-9793-9d8894a9117c
    langcode: en
    status: true
    dependencies:
      module:
        - node
        - text
    _core:
      default_config_hash: EBUo7qOWqaiZaQ_RC9sLY5IoDKphS34v77VIHSACmVY
    id: node.body
    field_name: body
    entity_type: node
    type: text_with_summary
    settings: {  }
    module: text
    locked: false
    cardinality: 1
    translatable: true
    indexes: {  }
    persist_with_no_fields: true
    custom_storage: false
    

    and running:

    drush sqlq "explain node__body;"
    

    produces:

    bundle	varchar(128)	NO	MUL		
    deleted	tinyint(4)	NO	PRI	0	
    entity_id	int(10) unsigned	NO	PRI	NULL	
    revision_id	int(10) unsigned	NO	MUL	NULL	
    langcode	varchar(32)	NO	PRI		
    delta	int(10) unsigned	NO	PRI	NULL	
    body_value	longtext	NO		NULL	
    body_summary	longtext	YES		NULL	
    body_format	varchar(255)	YES	MUL	NULL
    

    Doesn't this mean the storage config hasn't been purged?

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States mglaman WI, USA

    Correct. It's not about the field storage. I just re-read:

    Hi @mglaman - I think I found the reverse to be true ie. _removing_ the config for `field.storage.node.body` was the thing that prevented the optional config being installed and thus resolved the issue with an exception being thrown on install.
    

    I think I get it now. The original stack trace may have more info, but it's not about the storage at all. It's in _search_api_views_get_handlers. I guess having only a storage and not a field config causes the issue. It wasn't a hard crash for me. I was hoping it was a version issue, but I see you're on 1.28.0 and I am as well.

    The main reason I'm drilling down so much is that this seems like a bug somewhere that is from Drupal core or Search API, and our default config shouldn't be causing a magnificent crash whether they're the right approach or not.

  • Status changed to Active almost 2 years ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States mglaman WI, USA

    Okay, I reproduced. However it just logs exceptions via watchdog_exception and there is no crash. The body field is then removed from the index automatically.

    EDIT: I was only able to reproduce once I deleted all node types. So long as one existed this didn't occur. So I think it ties into anything bundle-field related with Search API.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States mglaman WI, USA

    @tomdearden given that this is preproducible, it seems to only happen once when the module is first installed and is logged versus causing a crashed Drupal site. Are you experiencing anything different than that?

    We're going to evaluate moving the index and view to a "defaults" or "example" module. I'm tempted to "Closed (won't fix) this since it's a weird condition caused by Search API when a field storage has no fields attached to bundles... or no bundles exist. I didn't chase down that far. But if it's causing a crash on the CLI or screen we should fix.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom tomdearden

    Hi @mglaman - it throws an ugly error when enabling the module via Drush but the command's return code is still zero so I don't think it would cause issues within the average CI pipeline, for example. See the attached screengrab for the kind of output that's shown.

    I really like the idea of moving the index and view to an optional module - that seems to fit the use case better as then they're optional by user choice, rather than by site configuration as the dependency model has it.

  • Status changed to Fixed almost 2 years ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States mglaman WI, USA

    Thanks for confirming, @tomdearden. I seriously appreciate your time and feedback on this issue.

    I have opened ๐Ÿ“Œ Move default search index and view into a "defaults" submodule Fixed . It looks like we may be able to slate that into our next sprint. I was going to close this ticket as " Closed (works as designed)" because it's an issue with fields and Search API. But then no one would get issue credits for helping. So I'm resolving as Fixed. Thanks for uncovering this.

  • Automatically closed - issue fixed for 2 weeks with no activity.

  • Status changed to Fixed over 1 year ago
  • ๐Ÿ‡จ๐Ÿ‡ดColombia angelgarciaco Bogotรก, Colombia

    Hey @mglaman some news about this (#21) ?

Production build 0.71.5 2024