Assertion error for Role

Created on 19 July 2025, 2 months ago

Hi there,

I created a dynamic scope with granularity set to "Role" and associated a role to it.

I got the appropriate access token with the appropriate scope. However, when I made a request, I got this error:

AssertionError: assert($role_storage instanceof RoleStorage) in assert() (line 86 of /home/site/wwwroot/web/modules/contrib/simple_oauth/src/Plugin/ScopeGranularity/Role.php)

After some debugging, I found that the $role_storage is a Drupal\user\RoleStorageDecorator which caused the exception.

Should the

assert($role_storage instanceof RoleStorage);

be removed or should we just check if the function

'isPermissionInRoles'

exists?

Thank you for your assistance!

🐛 Bug report
Status

Active

Version

6.0

Component

Code

Created by

🇦🇺Australia ajlow

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @ajlow
  • 🇳🇱Netherlands bojan_dev

    Is this a custom decorator? If it's the decorator of the RoleStorage, I would assume that it implements the RoleStorageInterface , it would then suffice todo the assertion base on the interface instead.

  • 🇦🇺Australia ajlow

    Hi @bonjan_dev, this is not a custom decorator. From what I can determine, it is in the version of the webprofiler module that I have installed and yes, it does implement RoleStorageInterface.

  • 🇳🇱Netherlands bojan_dev

    Oke check, then just replace the assertion to the interface. Can you please provide a MR for this?

  • 🇦🇺Australia ajlow

    Hi @bonjan_dev, I have pushed a commit to the 6.0.x branch which is different to the issue fork above which is to the 5.2.x.

    As for the 5.2.x issue fork, there is no changes for this branch as Role.php does not exist.

    Also, I noticed RoleStorage and RoleStorageInterface is marked for deprecation in Drupal 12 - https://www.drupal.org/node/3476166

    Please let me know if you have any questions or if I need to re-roll or update my changes.

    Thank you!

Production build 0.71.5 2024