Problem/Motivation

On Drupal 11, visiting the autocomplete route (/search_api_autocomplete/{search_api_autocomplete_search}) throws a fatal error:

RuntimeException: Callable "Drupal\search_api_autocomplete\Utility\AutocompleteHelper::access" requires a value for the "$search_api_autocomplete_search" argument. in Drupal\Component\Utility\ArgumentsResolver->handleUnresolvedArgument()
 

The cause is that the search_api_autocomplete.autocomplete route does not declare an explicit options.parameters entry for the {search_api_autocomplete_search} parameter. In Drupal 11, EntityConverter::applies() only upcasts a route parameter when the route explicitly declares type: entity:entity_type_id in options.parameters. Without this declaration, the parameter is never converted from a raw string to a SearchInterface entity object. When AutocompleteHelper::access() is invoked as an access checker, ArgumentsResolver cannot satisfy its SearchInterface $search_api_autocomplete_search argument and throws a
RuntimeException.

Steps to reproduce

  1. Install search_api_autocomplete 1.x on Drupal 11.
  2. Create and enable a Search API index with an autocomplete search entity.
  3. Make a request to /search_api_autocomplete/{search_id}?q=test.
  4. Observe the fatal RuntimeException from ArgumentsResolver.

Proposed resolution

Add an explicit options.parameters declaration to the search_api_autocomplete.autocomplete route in search_api_autocomplete.routing.yml so that Drupal's EntityConverter knows to upcast the route parameter to a SearchInterface
entity:

  search_api_autocomplete.autocomplete:
    path: /search_api_autocomplete/{search_api_autocomplete_search}
    defaults:
      _controller: \Drupal\search_api_autocomplete\Controller\AutocompleteController::autocomplete
    requirements:
      _search_api_autocomplete: 'TRUE'
    options:
      parameters:
        search_api_autocomplete_search:
          type: entity:search_api_autocomplete_search
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

eduardo morales alberti’s picture

Status: Active » Needs review

Ready to review

eduardo morales alberti’s picture

Status: Needs review » Needs work
eduardo morales alberti’s picture

Status: Needs work » Closed (won't fix)

The errors come from a deployment, on a route rebuilding, so it can be ignored, because Drupal already detects the type.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.