Fatal Error when using key module and key not defined.

Created on 14 May 2025, 24 days ago

When using the search_api_coveo_keys submodule, and you have configured a key using an environment variable, if that environment variable is not defined (null) a fatal type error is thrown. This causes the site not to bootstrap and drush commands fail.

<pre>The website encountered an unexpected error. Try again later.

TypeError: Drupal\search_api_coveo_keys\RepositoryManager::getKeyValues(): Return value must be of type array, null returned in Drupal\search_api_coveo_keys\RepositoryManager->getKeyValues() (line 32 of modules/contrib/search_api_coveo/modules/search_api_coveo_keys/src/RepositoryManager.php).
Drupal\search_api_coveo\CredentialProvider->getCredentials(Array) (Line: 126)
Drupal\search_api_coveo\Plugin\search_api\backend\SearchApiCoveoBackend::create(Object, Array, 'search_api_coveo', Array) (Line: 21)
Drupal\Core\Plugin\Factory\ContainerFactory->createInstance('search_api_coveo', Array) (Line: 83)
Drupal\Component\Plugin\PluginManagerBase->createInstance('search_api_coveo', Array) (Line: 152)
Drupal\search_api\Entity\Server->getBackend() (Line: 80)</pre>

This situation normally won't happen when setting things up locally, because the key module does provide form validation when saving the key. However, this situation can occur when using Drupal's configuration management to synchronize configuration between multiple environments and the environment variable has not been defined in the environment you are styling to.

πŸ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States chrissnyder Maryland

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024