When we import the exported config which has the Brightcove plugin installed, we get:

Uncaught TypeError: Argument 2 passed to
Drupal\jsonapi\Routing\Routes::Drupal\jsonapi\Routing\{closure}() must be an instance of
Drupal\jsonapi\ResourceType\ResourceType, null given in
drupal8/html/modules/contrib/jsonapi/src/Routing/Routes.php:354
Stack trace:
#0 [internal function]: Drupal\jsonapi\Routing\Routes::Drupal\jsonapi\Routing\{closure}(false, NULL)
#1
drupal8/html/modules/contrib/jsonapi/src/Routing/Routes.php(356):
array_reduce(Array, Object(Closure), false)
#2
drupal8/html/modules/contrib/jsonapi/src/Routing/Routes.php(274):
Drupal\jsonapi\Routing\Routes::hasNonInternalTargetResourceTypes(Array)
#3
drupal8/html/modules/contrib/jsonapi/src/Routing/Routes.php(176):
Drupal\jsonapi\Routing\Routes::getIndividualRoutesForResourceType(Object(Drupal\jsona in
drupal8/html/modules/contrib/jsonapi/src/Routing/Routes.php,
line 354

In our case, this fails, because Brightcove has an entity (BrightcoveVideo) that's defined programatically, which references another entity in its baseFieldDefinitions that's declared as in yaml file in "config/install". During initial plugin installation there's no problem, because the config is imported before the video entity is created. However, when running "drush config-import", the "baseFieldDefinitions" method is executed before the configuration is imported. Given that there's no agreement whether database updates should be executed before or after the configuration is imported I decided to open an issue here.

Intuition tells me that routes should only be generated after config is imported and database updates are executed.

Comments

toddkazakov created an issue. See original summary.

gabesullice’s picture

Project: JSON:API » Drupal core
Version: 8.x-2.x-dev » 8.6.x-dev
Component: Code » routing system
Issue tags: +API-First Initiative

Intuition tells me that routes should only be generated after config is imported and database updates are executed.

I think I agree with you, but that makes this a Drupal core issue. JSON:API doesn't control when routes are generated.

wim leers’s picture

Status: Active » Needs review
StatusFileSize
new1.62 KB

Hm, here's a thought, this might be able to solve it. But the config syncing process is so much of a black box to me, that it's really just a wild guess.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

borisson_’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll, +CMI 2.0 candidate, +Bug Smash Initiative

This patch probably did not apply for core, i'm not sure if this is actually still a problem, so we should probably start by checking if this is still an issue with the brightcove module

If it still applies, we also need tests, tagged with the CMI tag so the right people can also have a look at this to see if this is a good solution.

ravi.shankar’s picture

Issue tags: -Needs reroll
StatusFileSize
new1.77 KB

Added reroll of patch #3 on Drupal 9.4.x.

immaculatexavier’s picture

Status: Needs work » Needs review
StatusFileSize
new2.09 KB
new2.05 KB

Rerolled patch against #10

borisson_’s picture

Status: Needs review » Needs work

I'm not sure if this is actually still a problem, so we should probably start by checking if this is still an issue with the brightcove module.

Before the rerolling, it's more important to see if this is actually still needed.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.