Steps to reproduce:

1. Create a resource.
2. Enable it.
3. Disable it.
4. Change it's "id" in RestResource annotations section.
5. Clear cache.
6. Go to /admin/people/permissions.
7. See the error:

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "{MY OLD REST RESOURCE ID}" plugin does not exist.

Workaround

From Comment #9

1. drush config-export --yes
2. Find in your config folder yml file rest.resource.{YOUR_RESOURCE_NAME} and delete it.
3. drush config-import --yes
4. drush cache-rebuild for sure, and error will miss.


My workaround has been:

1. Go to "config" table.
2. Search for a value in "name" column with id: "rest.resource.{MY OLD REST RESOURCE ID}".
3. Delete it.

Comments

bdominguez created an issue. See original summary.

Wim Leers’s picture

Category: Bug report » Support request
Status: Active » Fixed

Renaming a REST resource plugin ID is not allowed while configuration is referring to it. The proper way to do this is:

  1. Delete REST resource config
  2. Rename plugin ID
  3. Create new REST resource config
bdominguez’s picture

But how I "Delete REST resource config" without doing it directly in database manually?

Wim Leers’s picture

If you uninstall the module that provides the REST resource plugin, you'll also have to uninstall the configuration that depends on it.

Therefore:

  1. uninstall (will also delete)
  2. rename
  3. reinstall
bdominguez’s picture

Ok, but sometimes you can't uninstall a module because you already have a configuration, schema, etc... attached and you will lose it.

I think that it would help other people to see my workaround and apply it in that cases.

Thanks.

Wim Leers’s picture

Yes, your suggested work-around is how somebody who knows his way around Drupal's innards would do it. :)

clemens.tolboom’s picture

Status: Fixed » Closed (works as designed)
Wim Leers’s picture

Priority: Major » Normal
Niklan’s picture

A workaround for those who will find it later.

1. drush cex -y actual configs.
2. Find in your config folder yml file rest.resource.{YOUR_RESOURCE_NAME} and delete it.
3. drush cim -y this change, it will be correctly removed from DB.
4. drush cr for sure, and error will miss.

Wim Leers’s picture

Thanks, @Niklan!

eugene.ilyin’s picture

A workaround for those who will find it later.

1. drush cex -y actual configs.
2. Find in your config folder yml file rest.resource.{YOUR_RESOURCE_NAME} and delete it.
3. drush cim -y this change, it will be correctly removed from DB.
4. drush cr for sure, and error will miss.

This solution works, thank you.
But the situation that I should act like this is awful. It's really not obvious and very inconvenient. I expect that if I disabled the resource and will remove the file where I defined it (not a config file) I will not get an error when I'll want to clear cache.

druplr’s picture

I did as explained in #9, but import failed with an error. But drush cdel rest.resource.{YOUR_RESOURCE_NAME} worked for me.

clemens.tolboom’s picture

Status: Closed (works as designed) » Active

Guess we could add a page somewhere.

Looking at links below I even wonder how to even "create a resource" ... is that documented somewhere or just wade through the API docs?

- https://www.drupal.org/docs/8/core/modules/rest
- https://www.drupal.org/docs/8/api/restful-web-services-api

Wim Leers’s picture

clemens.tolboom’s picture

Assigned: Unassigned » clemens.tolboom
Issue summary: View changes

Added #9 to summary.

I keep this open as a reminder to edit mentioned page (it uses dl,dd,dt in strange way)

clemens.tolboom’s picture

Assigned: clemens.tolboom » Unassigned
Status: Active » Closed (works as designed)

That's not going to work ... edit that page. Un-assigning and closing.

tjtj’s picture

I get a zillion error messages when I try to import the configuration like:

The import failed due to the following reasons:
  Configuration <em class="placeholder">analytic.settings</em> depends on the <em class="placeholder">analytic</em> extension that will n
  ot be installed after import.
  Configuration <em class="placeholder">block.block.analytic_search_form</em> depends on the <em class="placeholder">analytic</em> theme
  that will not be installed after import.
  Configuration <em class="placeholder">block.block.analytic_system_main</em> depends on the <em class="placeholder">analytic</em> theme
  that will not be installed after import.
  Configuration <em class="placeholder">block.block.analytic_system_powered_by</em> depends on the <em class="placeholder">analytic</em>
  theme that will not be installed after import.
  Configuration <em class="placeholder">block.block.analytic_user_login</em> depends on the <em class="placeholder">analytic</em> theme t
  hat will not be installed after import.
  Configuration <em class="placeholder">core.entity_form_display.node.adress_book_entry.default</em> depends on configuration (<em class=
clemens.tolboom’s picture

This has nothing to do with Rest UI but ...

Configuration block.block.analytic_system_powered_by depends on the analytic

suggests to manual enable the analytic module ... I get this annoyance not and then with other modules. I suspect myself adding too many modules and config changes Drupal gets in troubled waters.

MahmoudSayed96’s picture

Thanks, @druplr #12 works for me