Problem/Motivation
The GoogleApiServiceClient entity has a canonical route defined in its annotation, but this route is not defined in the routing file. This can cause the exception "Route "entity.google_api_service_client.canonical" does not exist".
For us this happened after some recent core updates, blocking config import.
I've found an old issue for this: https://www.drupal.org/project/google_api_client/issues/3449473, but this fix was only applied to the 3.x branch, the latest versions still have this issue.
Steps to reproduce
Steps described in https://www.drupal.org/project/google_api_client/issues/3449473 :
- Create at least one google_api_service_client entity
- Run the following with Drush:
( drush eval "$(cat)" ) <<-'PHP_CODE'
/** @var \Drupal\Core\Config\Entity\ConfigEntityStorageInterface $storage */
$storage = \Drupal::entityTypeManager()->getStorage('google_api_service_client');
$services = $storage->getQuery()->accessCheck(FALSE)->range(0, 1)->execute();
/** @var \Drupal\google_api_client\GoogleApiServiceClientInterface $client */
$client = $storage->load(array_key_first($services));
try {
$client->toUrl()->toString(TRUE)->getGeneratedUrl();
}
catch (\Exception $e) {
print 'Exception caught: ' . $e->getMessage() . PHP_EOL;
}
PHP_CODE
Proposed resolution
Apply the fix in https://www.drupal.org/project/google_api_client/issues/3449473 to the 4.x branch as well, this removes the canonical route from the annotation.
Alternatively, if the canonical route for this entity type is desired, it should be defined in the routing file.
Comments
Comment #2
thedut commentedHello,
I can confirm that the patch from #3449473 issue is still applicable via composer and fix this issue.
Comment #3
elaman