ERROR: AssertionError: Cannot load a NULL ID. in assert() (line 249 of core/lib/Drupal/Core/Entity/EntityStorageBase.php).

Where I encountered it / rough steps to reproduce:
The Drupal 8 group module has a two step form for creating content in a group. The first step (page) is to create the node. The second step creates the group content relationships (separate entity).

The node is not actually created until the entire process is complete.

Therefore, on initial node form submit, there is no NID, as the node has not been saved. The error is as follows:

 AssertionError: Cannot load a NULL ID. in assert() (line 249 of core/lib/Drupal/Core/Entity/EntityStorageBase.php).
assert(, 'Cannot load a NULL ID.') (Line: 249)
Drupal\Core\Entity\EntityStorageBase->load(NULL) (Line: 645)
Drupal\simple_sitemap\Simplesitemap->setEntityInstanceSettings('node', NULL, Array) (Line: 128)
simple_sitemap_entity_form_submit(Array, Object)
call_user_func_array('simple_sitemap_entity_form_submit', Array) (Line: 111)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 51)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 590)
Drupal\Core\Form\FormBuilder->processForm('node_basic_page_form', Array, Object) (Line: 319)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 61)
Drupal\Core\Entity\EntityFormBuilder->getForm(Object, 'default', Array) (Line: 361)
Drupal\group\Entity\Controller\GroupContentController->createForm(Object, 'group_node:basic_page')
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 693)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19) 
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jnicola created an issue. See original summary.

jnicola’s picture

Attached is a patch that I wrote which works around this. If there's no NID, no sense proceeding in simple_sitemap_entity_form_submit

gbyte’s picture

Please always open up bug reports against the module's dev version. Is this error present in the dev version, can you please test?

jnicola’s picture

Version: 8.x-3.3 » 8.x-3.x-dev

The error is present in the dev version, the patch works against the dev version.

I don't agree on always doing it against dev, nor the patch, but I'm not terribly motivated to articulate or ague the matter, especially since it doesn't matter here in the end.

  • gbyte.co committed 17a26cd on 8.x-3.x
    Issue #3080510 by jnicola, gbyte.co: Assertion error on multi-step form...
gbyte’s picture

Status: Active » Fixed

I don't agree on always doing it against dev, nor the patch, but I'm not terribly motivated to articulate or ague the matter, especially since it doesn't matter here in the end.

The process is not opinion based and your different opinion does not change the fact that fixes are pushed to the development version of modules and not retroactively to releases. So for a maintainer neither the patch, nor the report itself are useful if not created against the development version.

I have changed some logic and believe this should fix the issue, would you mind testing the dev version for me?

jnicola’s picture

Alright, we'll invest some time to disagree then :)

There is distinct value in using a stable and known good version of a module. People wishing to use a stable and known good branch may want to just patch against that branch. I also may not want whatever other code is in dev that hasn't been checked for security and other aspects as well, or may not have tests written for.

An example in action:

I've got the dev version of this in my composer file and this patch. Your change has been made now, and the next composer update fails on the patch. Any other changes in dev can also cause patches to fail to apply and then all of those need to be chased down, as dev is a moving target, versus a fixed release.

They wouldn't give us an option of version in the drop down if this wasn't the case :)

Rant aside, your code does seem to work at this time with the group module.

gbyte’s picture

There is distinct value in using a stable and known good version of a module. People wishing to use a stable and known good branch may want to just patch against that branch. I also may not want whatever other code is in dev that hasn't been checked for security and other aspects as well, or may not have tests written for.

No one is telling you not to use releases... they are just asking you to test the development version before creating a bug report as the issue might have been fixed already. Also feel free to write a patch against a release after you wrote one for the development version. Unless you don't want the bugs to ever get fixed and instead want to collect patches on top of your release.

They wouldn't give us an option of version in the drop down if this wasn't the case :)

That's for e.g support tickets, as you absolutely can request support for releases. I'm talking about bug reports.

Having an opinion is not an excuse to use it when it's uninformed. ;)

Rant aside, your code does seem to work at this time with the group module.

Good to hear! There will be a release as soon as the new submission to search engine functionality has been tested by the community.

jnicola’s picture

Ah see, now that's a fair bit of entitlement on just how much a person contributing should take! Do it on not just one branch, but TWO!

I'd love to see if there's some new community standard to this affect. It's in contradiction to my last 10 years doing this. I've got an axe to grind if so :)

jnicola’s picture

I should add, last I knew the standard was to search the issue queue before posting. Didn't see anything relevant.

gbyte’s picture

Ah see, now that's a fair bit of entitlement on just how much a person contributing should take! Do it on not just one branch, but TWO!

I realize there may come a day where I am profiting from using your software, but at this moment you talking about entitlement is a bit out of place, considering I am creating and fixing this module for you. Also, patches are optional, I just need you to create bug reports against the dev version.

jnicola’s picture

My apologies, I meant from the community at large if that's the case :) Anyways, reviewing documentation on it all, you are largely correct that's the standard going forward. I'll bother someone else about this.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.