Problem/Motivation

When I select "Meilisearch" in the "Add a server" interface at /admin/config/search/search-api/add-server, the setting panel for Meilisearch does not expand. In the Javascript console, the following message shows up:

{
    "message": "\nAn AJAX HTTP error occurred.\nHTTP Result Code: 200\nDebugging information follows.\nPath: /admin/config/search/search-api/add-server?ajax_form=1\nStatusText: parsererror\nResponseText: AssertionError: The container was serialized. in assert() (line 16 of /var/www/html/web/core/lib/Drupal/Core/DependencyInjection/Container.php).",
    "name": "AjaxError"
}

If I go ahead an save the server settings (without adding any Meilisearch-specific information), the following serverside error shows up:

The website encountered an unexpected error. Please try again later.
AssertionError: The container was serialized. in assert() (line 16 of core/lib/Drupal/Core/DependencyInjection/Container.php).
assert(, 'The container was serialized.') (Line: 16)
Drupal\Core\DependencyInjection\Container->__sleep()
serialize(Array) (Line: 14)
Drupal\Component\Serialization\PhpSerialize::encode(Array) (Line: 111)
Drupal\Core\KeyValueStore\DatabaseStorageExpirable->doSetWithExpire('form-6QyMFecKyNnvfP06o1cfLim9s5_lbuQRi2YpdMc5Bsg', Array, 21600) (Line: 122)
Drupal\Core\KeyValueStore\DatabaseStorageExpirable->setWithExpire('form-6QyMFecKyNnvfP06o1cfLim9s5_lbuQRi2YpdMc5Bsg', Array, 21600) (Line: 197)
Drupal\Core\Form\FormCache->setCache('form-6QyMFecKyNnvfP06o1cfLim9s5_lbuQRi2YpdMc5Bsg', Array, Object) (Line: 463)
Drupal\Core\Form\FormBuilder->setCache('form-6QyMFecKyNnvfP06o1cfLim9s5_lbuQRi2YpdMc5Bsg', Array, Object) (Line: 441)
Drupal\Core\Form\FormBuilder->rebuildForm('search_api_server_form', Object, Array) (Line: 633)
Drupal\Core\Form\FormBuilder->processForm('search_api_server_form', Array, Object) (Line: 325)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 169)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 718)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Steps to reproduce

1. Install and activate the module (v1.0.0 or 1.0.x-dev)
2. Activate the search_api_db module
3. Create new server (no backend plugin will be selected on the form)
4. Select backend "Database" and its configuration form is loaded
5. Select backend "Meilisearch" and the configuration form is not updated (the form stays from the Database plugin)
6. Save the form and the error is thrown

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

hktang created an issue. See original summary.

deaom’s picture

I tried recreating this issue on the clean Drupal install but can't. Not sure if this is actually a meili search issue or a search api issue. Did you try with a different server or on a clean install? Next option would also be to try it with dev version of module. Which version of Drupal are you using?

bcizej’s picture

Version: 1.0.0 » 1.0.x-dev
Issue summary: View changes

At first I could not reproduce this as well but then this line hit me

In the Javascript console, the following message shows up:

and I was able to reproduce the issue by installing other plugins. I had for a while suspected that the issue might be related with our dependencies that are injected into the plugin and that it might be connected with __sleep and __wakeup methods that de/serialize the plugin however we are testing on clean drupal instances and we only have Meilisearch plugin installed and as so the form is automatically set to select "Meilisearch" as backend plugin. Installing more modules that provide backend plugins makes this error reproducible.

I have updated the steps to reproduce. Thanks for the report!

bcizej’s picture

Issue summary: View changes

bcizej’s picture

Status: Active » Needs work

Added a test that reproduces the issue.

hktang’s picture

Thank you for picking this up. Yes, after I deleted other search API modules (db, solr, etc), the Meilisearch config panel is visible by default and saves correctly.

bcizej’s picture

Status: Needs work » Needs review

Rebased the branch and added a fix. The api service was not being removed from the plugin before serialization which caused the error.

deaom’s picture

Status: Needs review » Reviewed & tested by the community

With the updated steps to reproduce the issue, I was able to reproduce it. The correction from @bcizej is working as expected and it seems DB plugin has something similar implemented. I did correct 2 small CS issues (not from this issue) as did not want to open another ticket just for that. The tests are also passing so marking it as RTBC.

  • bcizej committed e4ef1db7 on 1.0.x
    Issue #3385294 by bcizej, DeaOm, hktang: AJAX HTTP error occurred when...
bcizej’s picture

Status: Reviewed & tested by the community » Fixed

Merged, thanks.

hktang’s picture

Thank you for your swift response! I confirm it works perfectly on my instance.

Status: Fixed » Closed (fixed)

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