Creating as a bug, maybe should be a support request, feel free to recategorize.
I have a profile which installs a custom module that provides a entity (myentity). As configuration provided by the profile (config/install/rest.settings.yml of the profile) I have:
'entity:myentity':
GET:
supported_formats:
- hal_json
supported_auth:
- cookie
'entity:user':
GET:
supported_formats:
- hal_json
supported_auth:
- cookie
On installation of this profile I get:
Original
Drupal\Component\Plugin\Exception\PluginNotFoundException: The "entity:myentity" plugin does not exist. in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 57 of /home/penyaskito/projects/wirimkiez/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).
Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition(Array, 'entity:myentity', 1)
Drupal\Core\Plugin\DefaultPluginManager->getDefinition('entity:myentity')
Drupal\Core\Plugin\Factory\ContainerFactory->createInstance('entity:myentity', Array)
Drupal\Component\Plugin\PluginManagerBase->createInstance('entity:myentity')
Drupal\rest\Plugin\Type\ResourcePluginManager->getInstance(Array)
Drupal\rest\Routing\ResourceRoutes->alterRoutes(Object)
Drupal\Core\Routing\RouteSubscriberBase->onAlterRoutes(Object, 'routing.route_alter', Object)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('routing.route_alter', Object)
Drupal\Core\Routing\RouteBuilder->rebuild()
Drupal\Core\Routing\RouteBuilder->rebuildIfNeeded()
Drupal\Core\Routing\RouteProvider->getRoutesByNames(Array)
Drupal\Core\Routing\RouteProvider->getRouteByName('')
Drupal\Core\Routing\UrlGenerator->getRoute('')
Drupal\Core\Routing\UrlGenerator->generateFromRoute('', Array, Array)
Drupal::url('')
template_preprocess_page(Array)
template_preprocess_maintenance_page(Array)
template_preprocess_install_page(Array, 'install_page', Array)
Drupal\Core\Theme\ThemeManager->theme('install_page', Array)
Drupal\Core\Theme\ThemeManager->render('install_page', Array)
Drupal\Core\Render\Renderer->doRender(Array, 1)
Drupal\Core\Render\Renderer->render(Array, 1)
Drupal\Core\Render\BareHtmlPageRenderer->renderBarePage(Array, 'Choose language', 'install_page', Array)
install_display_output(Array, Array)
install_drupal(Object)
Additional
RuntimeException: Recursive router rebuild detected. in Drupal\Core\Routing\RouteBuilder->rebuild() (line 128 of /home/penyaskito/projects/wirimkiez/core/lib/Drupal/Core/Routing/RouteBuilder.php).
Drupal\Core\Routing\RouteBuilder->rebuild()
Drupal\Core\Routing\RouteBuilder->rebuildIfNeeded()
Drupal\Core\Routing\RouteProvider->getRoutesByNames(Array)
Drupal\Core\Routing\RouteProvider->getRouteByName('')
Drupal\Core\Routing\UrlGenerator->getRoute('')
Drupal\Core\Routing\UrlGenerator->generateFromRoute('', Array, Array)
Drupal::url('')
template_preprocess_page(Array)
template_preprocess_maintenance_page(Array)
template_preprocess_install_page(Array, 'install_page', Array)
Drupal\Core\Theme\ThemeManager->theme('install_page', Array)
Drupal\Core\Theme\ThemeManager->render('install_page', Array)
Drupal\Core\Render\Renderer->doRender(Array, 1)
Drupal\Core\Render\Renderer->render(Array, 1)
Drupal\Core\Render\BareHtmlPageRenderer->renderBarePage(Array, 'Error', 'install_page', Array)
install_display_output(Array, Array)
_drupal_log_error(Array, 1)
_drupal_exception_handler(Object)
Comments
Comment #1
penyaskitoDiscussed with berdir and alexpott on IRC about the option to add config entities, but this does not really refer to entities but to plugins, so maybe is not viable.
alexpott suggested something like the fix attached. This would need tests, but not sure how we should test it.
Works perfectly for me on my usecase.
Comment #2
penyaskitoREST module is probably the component that fits better with the attached patch at #1.
Comment #4
larowlanWorking on fails
Comment #5
Alumei commentedI think this only hides the problem as the configuration states that it should be enabled but we silently ignore it because the plugin is not found.
I think config entities for endpoint configuration would enable the usage of optional configuration. Such config entity could have a dependency on the module that provides the entity type. In that case it should be installed during the installation of that module.
This should also make it possible to remove the implicit dependency of rest.settings on the node module if such a config entity would be provide for a node rest endpoint.
Comment #6
Alumei commentedI just finished the last bit of work on #2308745-106: Remove rest.settings.yml, use rest_resource config entities, which should resolve this issue as well.
Feel free to take a look ;-)
Comment #7
MattA commentedThis does not just occur during profile install. It also occurs in the following scenario:
- A contrib module with a REST plugin is installed.
- The endpoint is enabled, likely using the RestUI module.
- The contrib module is uninstalled.
- If caches are now flushed, routes are rebuilt, and the exception occurs.
Also going to update the title as this is really about plugins/plugin derivatives created for entities (and doesn't really have anything to do with entities themselves).
Comment #9
klausiSo this should have a comment like "Silently ignore resources that are in the settings but are not defined on the plugin manager currently. That avoids exceptions when REST module is enabled before another module that provides the resource plugin specified in the settings."
A test case should cover this scenario of enabling REST module before node module.
Comment #10
wim leersAFAICT #2308745: Remove rest.settings.yml, use rest_resource config entities would solve this on a more fundamental level. So, it's better. OTOH, it's also going to take some time until it's fixed.
So, I propose to do this now, and incorporate the proposed comment of #9, but also include a
Comment #11
wim leersComment #12
wim leersThe test-only patch is also the interdiff.
Comment #15
dawehnerLooks pretty good for itself. There is just this damn test failure.
Comment #16
wim leersPatch doesn't apply. Because I didn't do it on latest 8.1. Silly me.
Rebased. Identical to what I posted in #12, just rebased.
Comment #17
wim leersComment #18
dawehnerThere we go.
Comment #20
wim leersMarked #2609152: Rest plugins can cause fatal's during route rebuild as a duplicate. That was major, bumping this to major.
Comment #21
wim leersYet another duplicate found: #2351353: What to do with "Recursive router rebuild detected." (also major).
Comment #22
MattA commentedJust wanted to note that #2609152 also contained a bit of code to try and partially solve the underlying problem instead of just masking it like this. Theoretically, it is possible for invalid references to accumulate in rest.settings right now, which may or may not be a problem down the road.
Comment #23
wim leersBut it did not *really* solve anything. Only #2308745: Remove rest.settings.yml, use rest_resource config entities can really solve this entire problem.
Comment #24
MattA commentedYep. The same can be said about this patch though. It's really a question of how far we are willing to go to minimize the problem right now before that one lands. The most important part is probably the fatal error though, so I'm fine with either solution. Just wanted to note it so that all the relevant information is available before a decision is made. :)
Comment #25
wim leers@MattA++ :)
Comment #26
catchWhat about a trigger_error() there to at least inform people there's an issue if things go out of sync?
Comment #27
wim leersThere you go.
Comment #28
dawehnerWhat about listing which ones actually are missing/problematic ?
Comment #29
wim leersDone.
Comment #30
dawehnerThank you
Comment #31
alexpottA nice solution to solve the current problems until we can do #2308745: Remove rest.settings.yml, use rest_resource config entities.
Committed e9cafdf and pushed to 8.0.x and 8.1.x. Thanks!