Skip to content
This repository has been archived by the owner on Oct 11, 2023. It is now read-only.

TypeError: Cannot read property 'reduce' of undefined when trying to edit a role in Users & Permissions Plugin #31

Closed
aminta opened this issue Nov 23, 2020 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@aminta
Copy link

aminta commented Nov 23, 2020

When trying to edit a role in Users & Permissions Plugin the page briefly loads, then I get "an error occurred" modal and this error in the console:

TypeError: Cannot read property 'reduce' of undefined at Object.getRole (/Users/davide/Sviluppo/App/node_modules/strapi-plugin-users-permissions/services/UsersPermissions.js:200:42) at async Object.getRole (/Users/davide/Sviluppo/App/node_modules/strapi-plugin-users-permissions/controllers/UsersPermissions.js:92:18) at async /Users/davide/Sviluppo/App/node_modules/strapi/lib/middlewares/router/utils/routerChecker.js:79:22 at async /Users/davide/Sviluppo/App/node_modules/strapi-utils/lib/policy.js:68:5 at async /Users/davide/Sviluppo/App/node_modules/strapi/lib/middlewares/parser/index.js:48:23 at async /Users/davide/Sviluppo/Appnode_modules/strapi/lib/middlewares/xss/index.js:26:9 [2020-11-23T18:20:17.225Z] debug GET /users-permissions/roles/2xmxFW0T9DJK0Y6dCYmU (661 ms) 500

Strapi 3.3.3
strapi-connector-firestore ^3.0.0-alpha.22

@brettwillis
Copy link
Member

Thanks for the bug report. I may not get a chance to look at this in depth until next week. From a glance, it seems that the permissions field doesn't exist on the role object that is fetched from Firestore.

https://github.com/strapi/strapi/blob/6b6c1e2f7d5ae969f92b6f9a9b145944df53cda3/packages/strapi-plugin-users-permissions/services/UsersPermissions.js#L200

This could be either

  1. The permissions field isn't set in Firestore,
  2. Or the permissions field is being removed by this connector because of some bug

In the meantime before I get a chance to look at this, you could help me to narrow down by checking if #1 is the case. Could you look at the Firestore data in your Firebase Console, look at the "roles" collection, find the document "2xmxFW0T9DJK0Y6dCYmU" and see if there is any value for the permissions field?

@brettwillis brettwillis self-assigned this Nov 23, 2020
@aminta
Copy link
Author

aminta commented Nov 23, 2020

In Firestore I have a "users-permissions_role" collection with a "2xmxFW0T9DJK0Y6dCYmU" document.

@brettwillis
Copy link
Member

Ok and does that document have any value set for the permissions field?

@aminta
Copy link
Author

aminta commented Nov 23, 2020

No, these are the fields:

description : "Default role given to authenticated user." name : "Authenticated" type: "authenticated"

@brettwillis
Copy link
Member

Ok, thanks for that info. I'll take a look at this as soon as I get the chance.

@brettwillis
Copy link
Member

Please try 3.0.0-alpha.23 and let me know if this has resolved it for you?

@brettwillis brettwillis added the bug Something isn't working label Nov 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants