GoogleApiServiceClient canonical route not defined in routing file

Created on 27 March 2025, 11 days ago

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 🐛 GoogleApiServiceClient canonical route Fixed , 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 🐛 GoogleApiServiceClient canonical route Fixed :

- 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 🐛 GoogleApiServiceClient canonical route Fixed 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.

🐛 Bug report
Status

Active

Version

4.5

Component

Code

Created by

🇧🇪Belgium Joris Handstanger

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

Comments & Activities

Production build 0.71.5 2024