Cannot create Search API based views On Drupal 11

Created on 20 June 2025, about 1 month ago

Iโ€™m encountering a major compatibility issue between the Search API module and the core Views module.

Environment:

  • Drupal 11.2.0 (clean installation using drush site:install)
  • Search API 8.x-1.38

Steps to reproduce:

  1. Create a test search server (using the database backend).
  2. Create a search index with just one field, it does not matter which field you add.
  3. Create a new view using the search index as the data source.

Issue:
In the view configuration, under both the page and block display settings, the "Format" dropdown includes three options:

  • (empty value) (machine name: search_api_data)
  • Fields
  • Rendered entity

Selecting the index triggers the following error messages, even if no page or block display is created:

The submitted value search_api_data in the "Output as" element is not allowed.
The submitted value search_api_data in the "Feed row style" element is not allowed.

Additionally, some warnings are logged immediately upon selecting the search index as the data source (see log output below).

Warning: Undefined array key "title" in Drupal\views\Views::fetchPluginNames() (line 157 of /var/www/html/web/core/modules/views/src/Views.php)

#0 /var/www/html/web/core/includes/bootstrap.inc(104): _drupal_error_handler_real()
#1 /var/www/html/web/core/modules/views/src/Views.php(157): _drupal_error_handler()
#2 /var/www/html/web/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php(233): Drupal\views\Views::fetchPluginNames()
#3 /var/www/html/web/core/modules/views_ui/src/ViewAddForm.php(150): Drupal\views\Plugin\views\wizard\WizardPluginBase->buildForm()
#4 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityForm.php(107): Drupal\views_ui\ViewAddForm->form()
#5 /var/www/html/web/core/modules/views_ui/src/ViewFormBase.php(42): Drupal\Core\Entity\EntityForm->buildForm()
#6 [internal function]: Drupal\views_ui\ViewFormBase->buildForm()
#7 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(528): call_user_func_array()
#8 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(370): Drupal\Core\Form\FormBuilder->retrieveForm()
#9 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(625): Drupal\Core\Form\FormBuilder->rebuildForm()
#10 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(321): Drupal\Core\Form\FormBuilder->processForm()
#11 /var/www/html/web/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm()
#12 [internal function]: Drupal\Core\Controller\FormController->getContentResult()
#13 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
#14 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(622): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#15 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer->executeInRenderContext()
#16 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
#17 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(183): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#18 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#19 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle()
#20 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#21 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#22 /var/www/html/web/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle()
#23 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(116): Drupal\big_pipe\StackMiddleware\ContentLength->handle()
#24 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(90): Drupal\page_cache\StackMiddleware\PageCache->pass()
#25 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle()
#26 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#27 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(53): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#28 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle()
#29 /var/www/html/web/core/lib/Drupal/Core/DrupalKernel.php(715): Drupal\Core\StackMiddleware\StackedHttpKernel->handle()
#30 /var/www/html/web/index.php(19): Drupal\Core\DrupalKernel->handle()
#31 {main}

Impact:
This issue effectively blocks the creation of any Views using a Search API index.

Notes:
The same setup works correctly on Drupal 10.4.8, so this appears to be a regression in Drupal 11 compatibility.

๐Ÿ› Bug report
Status

Active

Version

1.38

Component

General code

Created by

๐Ÿ‡ฎ๐Ÿ‡นItaly finex

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

Merge Requests

Comments & Activities

  • Issue created by @finex
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium bramvandenbulcke

    There is a Drupal core issue about issues with Views on non-English setups. I have troubles with all the Views at the moment.

    See https://www.drupal.org/project/drupal/issues/2987548 ๐Ÿ› LogicException: The database connection is not serializable. Postponed: needs info .

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly finex

    I think it's a different bug because I've done a test using an english setup.

  • ๐Ÿ‡ท๐Ÿ‡ดRomania stefan.butura

    I am having the same issue on an English setup.

    Downgrading from Drupal 11.2.1 to 11.1.8 fixed the issue.

  • ๐Ÿ‡ณ๐Ÿ‡ดNorway vegardjo

    Same issue, fresh installs, english only. Last one is a fresh install with only Gin and search_api as contributed modules. Also reported here ๐Ÿ› The submitted value [value] in the [name] element is not allowed. Active .

  • Pipeline finished with Success
    21 days ago
    Total: 359s
    #536881
  • ๐Ÿ‡ณ๐Ÿ‡ดNorway vegardjo

    I took a stab at this, seems the search_api_data plugin is loaded later in 11.2 than before, so in search_api_views_plugins_row_alter() we now create it with too little info, rather than expanding on it. The plugin is only used for data exports, like a rest export view display, and is not available before you create a display like that.

    • Tested only on 11.2.2 for now
    • Tested that the plugin is available for a REST export display, after enabling core rest module
  • ๐Ÿ‡ง๐Ÿ‡ทBrazil hfernandes

    I was having this issue and the patch fixed it here.
    Drupal 11.2.2
    Search API 8.x-1.38

  • ๐Ÿ‡น๐Ÿ‡ญThailand peterbkk

    I'm having this issue also on Drupal 11.2.2 Search API 8.x-1.38, any solutions? @hfernandes which patch did you use?

  • ๐Ÿ‡ธ๐Ÿ‡ฎSlovenia deaom

    Having the same issue on D11.2.2, where a search api view can't be created, because of the "Format" dropdown which includes three options, as mentioned in the issue summary. Once the patch is applied, the empty value is no longer present for selection and Fields or Rendered entity can be selected and view created.

  • ๐Ÿ‡ง๐Ÿ‡ทBrazil hfernandes

    I spent some time reviewing this issue and trying to identify the root cause - and I believe Iโ€™ve finally found it.

    The search_api_data plugin extends DataEntityRow, which belongs to the rest module.
    On websites where the rest module is not enabled, the plugin discovery fails to locate the DataEntityRow definition, causing the search_api_data plugin to break.

    Here are a few possible solutions that could be implemented in the search_api module:

    1. If search_api_data relies on the rest module, then search_api should declare rest as a dependency and enable this module.
    2. Create a new search_api_rest submodule that depends on the rest and contains the search_api_data plugin.
    3. Refactor the search_api_data plugin to extend RowPluginBase instead of DataEntityRow.

    Among the three, I believe the third option is preferable, as it would have the least impact on websites currently using the search_api_data plugin.

  • ๐Ÿ‡ณ๐Ÿ‡ดNorway vegardjo

    I'm not sure this needs more work, even though it could likely be solved differently.

    The plugin is not directly tied to Rest module. If you create a view display of stream / feed / RSS (can't remember the name now), you will also use the plugin, but without Rest module.

    I believe the change that happened in 11.2 is when these plugins are discovered, and that there are some optimalisations in place to lazy load / load on demand plugins, that was not there before 11.2.

    If you do a dump of the plugin in d10 you will see that it exists already at /admin/structure/views (screenshot), but if you do the same in d11 you will see that it is null. The alter code is adding a ['base'] to the defined plugin, which is fine, but when the plugin is not defined it will rather create a broken plugin definition, with only the ['base'] info, which is what breaks the UI.

    The MR simply checks if it exist before it alters it, so it should be very safe. It could be tested further if there are any problems creating displays that uses search_api_data in 11.2, like the bases are not added, but in my limited testing everything seemed fine.

    Setting back status, but please just change it again if there is something I have not grasped completely here :)

  • ๐Ÿ‡ณ๐Ÿ‡ดNorway vegardjo
  • ๐Ÿ‡ง๐Ÿ‡ทBrazil hfernandes

    @vegardjo I'm not opposed to the current fix, as it makes sense to check if the plugin exists before accessing its attributes. However, this solution doesn't address the root cause of the issue. The problem lies in the search_api_data plugin failing to be instantiated - not due to lazy loading, but due to an architectural oversight.

    This plugin extends Drupal\rest\Plugin\views\row\DataEntityRow which is defined in the rest module. Relying on a module without declaring it as a dependency is problematic. In fact, simply enabling the rest module resolves the issue without applying the patch.

    In Drupal 11.2, this may have been addressed through improved plugin discovery that respects enabled modules.

    From what Iโ€™ve gathered, the Entity (Search API) plugin is intended for use specifically with REST export displays. If thatโ€™s confirmed to be the case, then one of the earlier options I suggested - either declaring a dependency or moving the plugin to a dedicated submodule - might be a more appropriate and sustainable fix.

  • ๐Ÿ‡ณ๐Ÿ‡ดNorway vegardjo

    Thanks for the thorough explanation, @hfernandes, I see now that I was indeed wrong in my assessment that the class / plugin is not directly tied to the Rest module.

    Given that I agree that your options 2 or 3 seems best way forward. I assume most SAPI use cases does not involve Rest exports, so having Rest as a dependency on SAPI itself seems overkill.

    Untill this is done the solution to the original problem is then either:

    • Apply the MR as it is now, as it will atleast allow you to create normal SAPI views again
    • Enable Rest module
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly finex

    I agree with the @hfernandes solution. The easiest solution would be to simply set the rest module as required.

  • Pipeline finished with Canceled
    8 days ago
    Total: 217s
    #547269
  • Pipeline finished with Failed
    8 days ago
    Total: 352s
    #547275
  • Pipeline finished with Failed
    8 days ago
    Total: 396s
    #547302
  • Pipeline finished with Failed
    8 days ago
    Total: 364s
    #547311
  • ๐Ÿ‡ง๐Ÿ‡ทBrazil hfernandes

    I've decided to move this implementation to a submodule, as enabling the rest module may not be appropriate for all websites.

    The tests are still failing because we need to migrate the PHPUnit test that validates the views_rest test case to the new submodule.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly finex

    Good idea @hfernandes, thank you! If I managed to find some time today, I would like to try the MR

  • Pipeline finished with Canceled
    7 days ago
    Total: 129s
    #548322
  • Pipeline finished with Failed
    7 days ago
    Total: 362s
    #548323
  • ๐Ÿ‡ง๐Ÿ‡ทBrazil hfernandes

    I've fixed the unit tests.
    However, there is one unit test still failing that I don't think is related to this change - Drupal\Tests\search_api_db_defaults\Functional\IntegrationTest - perhaps related to ๐Ÿ› Replace deprecated REQUIREMENT_ERROR constant in search_api_db_defaults_requirements() for Drupal 11+ compatibility Active

    I'm moving this to Needs review.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States averagejoe3000 Swanzey, NH

    I ran into this exact issue using Drupal 11.2.2. I applied the patch from merge request 247 and can confirm that fixed the issue for me.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States j-phat

    can confirm patching working on 11.2.2.

    thank you @hfernandes

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly finex

    Seems okay to me too, thanks.

Production build 0.71.5 2024