The domain entity type declares a collection link template pointing at /admin/config/domain, in domain/src/Entity/Domain.php.
Core derives the route name from the link relation, so $domain->toUrl('collection') resolves the route entity.domain.collection. The module declares that path under the route name domain.admin instead, in domain/domain.routing.yml, so the route does not exist and the call throws Symfony\Component\Routing\Exception\RouteNotFoundException.
To reproduce, on any site with a domain record:
\Drupal::entityTypeManager()->getStorage('domain')->load('example_com')->toUrl('collection');
Nothing in the module calls that relation today, which is why it has gone unnoticed, but any generic entity code that follows the declared link templates hits it. Found while writing the tests for #3613276: Replace the deprecated uri_callback entity type property.
Proposed resolution
Core solved the same problem for its own entity types by declaring the derived route name as an alias of the legacy route, see entity.node.add_form in node.routing.yml and entity.block_content_type.add_form in block_content.routing.yml. Do the same here:
entity.domain.collection: alias: domain.admin
Route aliases are resolved by name in RouteProvider::getRouteByName() and are excluded from path matching in getRoutesByPath(), so the listing page is still served by the domain.admin route. Every local task that declares base_route: domain.admin, every menu link that declares parent: domain.admin, the hook_help() case and every call to Url::fromRoute('domain.admin') in a dependent module keep working unchanged. No rename, no deprecation, no upgrade step.
Renaming domain.admin to entity.domain.collection and updating every reference, as first proposed, is a backwards compatibility break for any module that declares base_route: domain.admin in a local task or calls Url::fromRoute('domain.admin'), for example domain_theme_switch, domain_path, domain_entity and domain_menu_access, so the alias is preferred.
Route aliases were added in Drupal 11.2. The 4.x branch requires ^11.4 || ^12 so it can use them, while the 3.x branch still supports ^10.2, where an alias key has no handler and raises a TypeError while the router is rebuilt. The 3.x branch therefore keeps the bug until its core requirement is raised.
Remaining tasks
Review the merge request.
Out of scope: the module declares the route entity.domain.add rather than the conventional entity.domain.add_form. No add-form link template is declared, so there is no bug today. DomainDeleteForm::getCancelUrl() also becomes redundant once the collection relation resolves, which is a separate cleanup.
Issue fork domain-3613844
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
Comment #3
mably commentedComment #4
mably commentedComment #6
mably commentedComment #8
idebr commentedI opened #3615914: Remove Drupal\domain\Form\DomainDeleteForm in 4.x for this cleanup