I created some flags on my site (ver 8.9.2), specifically for media entities (video and image). I then created a media view with a few exposed filters and a global VBO field. When I try and run VBO and update that flag for media entities I'm met with the following error.

Full error

An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /batch?id=184442&op=do_nojs&op=do
StatusText: OK
ResponseText: AssertionError: Cannot load the "flag" entity with NULL ID. in assert() (line 249 of /var/www/html/docroot/core/lib/Drupal/Core/Entity/EntityStorageBase.php).

Comments

phernand42 created an issue. See original summary.

Julia Mykhaliak’s picture

It happens to me after adding relationship 'Content flag' on view, then after reloading view I am getting error
Flag 8.x-4.0-beta2, Drupal 8.8.5

Warning: assert(): Cannot load the "flag" entity with NULL ID. failed in /var/www/drupal/docroot/core/lib/Drupal/Core/Entity/EntityStorageBase.php on line 249

Warning: array_flip(): Can only flip STRING and INTEGER values! in /var/www/drupal/docroot/core/lib/Drupal/Core/Entity/EntityStorageBase.php on line 266

Julia Mykhaliak’s picture

Priority: Normal » Major
Status: Active » Needs work
phernand42’s picture

Issue summary: View changes
ptmkenny’s picture

Priority: Major » Normal
Status: Needs work » Active

@Julia Mykhaliak Please check the Drupal.org issue status descriptions. "Active" is for issues that don't have a patch; "Needs work" is for issues that do have a patch. This issue has no patch, so it is active.

arun_kv’s picture

I get the same issue when I use flag on contact messages. I am not using VBO module.

nejcramsak’s picture

Status: Active » Needs review
StatusFileSize
new611 bytes

Hi, i added a check that fixes this warning. Needs review.

brandonratz’s picture

Status: Needs review » Reviewed & tested by the community

In my case this happened after having an existing Flag relationship in the View. After adding a new Flag entity I received this warning.

Patch #7 fixed error

michelle’s picture

StatusFileSize
new978.9 KB
new1.02 MB

I am having this issue and the patch didn't help. In my case, the action works when it's done from admin/content. It gets the error when done from a custom view of Publication type nodes. I also have a notice right before the error that isn't shown in the OP:

Notice:  Undefined index: flag_id in /var/www/html/web/modules/contrib/flag/src/Plugin/Action/FlagAction.php on line 62
AssertionError: Cannot load the "flag" entity with NULL ID. in assert() (line 295 of /var/www/html/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php).

I put a breakpoint in at the line for the notice and the stack is very different between where it works and where it doesn't and the config is coming up empty. I'm not sure where to go from here in debugging. Any ideas?

Working:

Not working:

jurgenhaas’s picture

We are currently facing the same issue with the ECA module, see #3268552: Flag action isn't compatible with ECA

What we do over there is the create a list of all available actions through the action plugin manager form Drupal core. The problem seems to be that the flag module only registers 2 actions through it deriver. Instead, I think the deriver should register 2 actions for each configured flag config entity. That way, everybody could operate with those actions by having access to all of the configuration for each of them.

There is also an issue that's about integrating the flag module with ECA, so it looks there is real interest in getting this fixed. See #3238783: Integrate with ECA

delacosta456’s picture

hi
Patch #7 worked for me too with distro Open social 11.05 (D9.2)

Thanks

dries arnolds’s picture

I ran into this issue today. In my opinion integration with other modules is the core of what Flag is useful for, so this is probably important.

  • Berdir committed b316737 on 8.x-4.x authored by nejcramsak
    Issue #3163338 by nejcramsak: AssertionError: Cannot load the "flag"...
berdir’s picture

Status: Reviewed & tested by the community » Fixed

#9 that's a similar error in a different class, this is about views relationship.

Status: Fixed » Closed (fixed)

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