Facets cause logic error where leaked metadata was detected

Created on 25 July 2024, 4 months ago
Updated 26 July 2024, 4 months ago

Problem/Motivation

I am encountering an error when adding a facet to my Drupal Search API Decoupled endpoint. The error message is:

LogicException: The controller result claims to be providing relevant cache metadata, but leaked metadata was detected. Please ensure you are not rendering content too early. Returned object class: Drupal\Core\Cache\CacheableJsonResponse. in Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (line 154 of core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php).

This issue seems to be related to the handling of cache metadata in the facet module within the Search API Decoupled endpoint. The error does not occur in my local environment (without access to the Solr index and it returns no results) but manifests when using an Acquia Search API Solr server in the development environment.

Locally the facets return as expected, I don't have any results but I can see the facet in the facets array

{
  "search_results": [],
  "search_results_per_page": 10,
  "search_results_count": 0,
  "search_results_page": 0,
  "search_results_pages": 0,
  "facets": [
    {
      "label": "Knowledge Type",
      "key": "facet_knowledge_type",
      "count": 0,
      "active_values": [],
      "results": []
    }
  ],
  "took": 1152.55,
  "max_score": 0
}

Steps to reproduce

Be on Drupal 10.1.8 with the following other module versions:

  • Search API: 8.x-1.35
  • Facets: 2.0.7
  • Search API Decoupled Facets: 1.0.0-alpha36
  1. Install the search api decoupled module and enable it
  2. Create an endpoint for the Acquia Search index
  3. Add any facet to the endpoint
  4. Make a GET request to the endpoint and get the error

Proposed resolution

Not sure

Remaining tasks

Not sure

User interface changes

N/A

API changes

Not sure

Data model changes

N/A

πŸ’¬ Support request
Status

Active

Version

1.0

Component

Facets

Created by

πŸ‡ΏπŸ‡¦South Africa steven.jordaan

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.

No activities found.

Production build 0.71.5 2024