Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sequelize findOrCreate(...).spread is not a function #310

Closed
jason-fox opened this issue Jan 6, 2023 · 2 comments
Closed

Sequelize findOrCreate(...).spread is not a function #310

jason-fox opened this issue Jan 6, 2023 · 2 comments

Comments

@jason-fox
Copy link
Contributor

Can’tpass an Updated Policy Set to Authzforce

Related FIWARE/tutorials.Administrating-XACML#9

Updating an existing XACML role should cause Keyrock to sent an updated Policy set to Authzforce:

curl -X POST \
   http://localhost:3005/v1/applications/tutorial-dckr-site-0000-xpresswebapp/roles/security-role-0000-0000-000000000000/permissions/alrmbell-ring-24hr-xaml-000000000000 \
   -H 'Content-Type: application/json' \
   -H 'X-Auth-token: aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'

The actual result is an Internal Error in Keyrock:

2023-01-06T08:19:59.371Z idm:api-role_permission_assignments --> create
TypeError: models.role_permission.findOrCreate(...).spread is not a function
    at exports.create (/opt/fiware-idm/controllers/api/role_permission_assignments.js:80:8)
    at ....

Looking at role_permission_assignments.js, it is assuming that the model is returning an Array - but with Sequelize 6 it returns a Promise<Model, boolean> - the function signature has changed between Sequelize 4 and Sequelize 6

    models.role_permission
      .findOrCreate({
        where: { role_id: req.role.id, permission_id: req.permission.id },
        defaults: { role_id: req.role.id, permission_id: req.permission.id }
      })
      .spread(function (assignment, created) { ...

... so I think that with the update to Sequelize 6 the code needs updating

The .findOrCreate{}.spread() paradigm is used in multiple places in the code base, can you check which functions have not been updated and fix and test them.

@sanpago
Copy link
Member

sanpago commented Jan 9, 2023 via email

@jason-fox
Copy link
Contributor Author

Thanks for that @sanpago - will there be a Docker image made available (e.g. updated 8.3.1 or 8.3.2 maybe?) which includes this fix, so that the tutorial can be updated?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants