FIWARE / tutorials.Step-by-Step

Tutorials for the complete 𝑭𝑰𝑾𝑨𝑹𝑬 ecosystem for developers wishing to learn how to use NGSI-v2 and NGSI-LD and design context-based Smart Systems π’‘π’π’˜π’†π’“π’†π’…-π’ƒπ’š-𝑭𝑰𝑾𝑨𝑹𝑬.
https://fiware.github.io/tutorials.Step-by-Step/
MIT License
74 stars 70 forks source link

Identity Management tutorial - Keyrock user update fails #35

Open MNXOnline opened 4 years ago

MNXOnline commented 4 years ago

When updating a user with the following postman collection payload:

{
    "user": {
        "username": "alice",
        "email": "alice@test.com",
        "enabled": true,
        "gravatar": false,
        "date_password": "2018-07-26T15:25:14.000Z",
        "description": "Alice works for FIWARE",
        "website": "http://www.fiware.org"
    }
}

The response given is correct and the log show the following:

Tue, 22 Sep 2020 11:59:10 GMT idm:api-authenticate  --> validate_token
Executing (default): SELECT `AuthToken`.`access_token`, `AuthToken`.`expires`, `AuthToken`.`valid`, `AuthToken`.`user_id`, `AuthToken`.`pep_proxy_id`, `User`.`id` AS `User.id`, `User`.`username` AS `User.username`, `User`.`email` AS `User.email`, `User`.`date_password` AS `User.date_password`, `User`.`enabled` AS `User.enabled`, `User`.`admin` AS `User.admin`, `PepProxy`.`id` AS `PepProxy.id` FROM `auth_token` AS `AuthToken` LEFT OUTER JOIN `user` AS `User` ON `AuthToken`.`user_id` = `User`.`id` LEFT OUTER JOIN `pep_proxy` AS `PepProxy` ON `AuthToken`.`pep_proxy_id` = `PepProxy`.`id` WHERE `AuthToken`.`access_token` = 'f8ce4ca3-a512-4c50-9f86-aebaa6a694fb';
Tue, 22 Sep 2020 11:59:10 GMT idm:api-users --> load_user
Executing (default): SELECT `id`, `username`, `email`, `enabled`, `admin`, `image`, `gravatar`, `date_password`, `description`, `website` FROM `user` AS `User` WHERE `User`.`id` = '9b038c24-035d-43bf-9e03-b3af5d70f226';
Tue, 22 Sep 2020 11:59:10 GMT idm:api-users --> update
Executing (default): SELECT `id`, `username`, `description`, `website`, `image`, `gravatar`, `email`, `salt`, `password`, `date_password`, `enabled`, `admin`, `starters_tour_ended`, `eidas_id`, `extra`, `scope` FROM `user` AS `User` WHERE `User`.`email` = 'alice@test.com';
Executing (default): SELECT `id`, `username`, `description`, `website`, `image`, `gravatar`, `email`, `salt`, `password`, `date_password`, `enabled`, `admin`, `starters_tour_ended`, `eidas_id`, `extra`, `scope` FROM `user` AS `User` WHERE `User`.`email` = 'alice@test.com';
Executing (default): UPDATE `user` SET `username`='alice',`email`='alice@test.com',`description`='Alice works for FIWARE',`website`='http://www.fiware.org' WHERE `id` = '9b038c24-035d-43bf-9e03-b3af5d70f226'
PATCH /v1/users/9b038c24-035d-43bf-9e03-b3af5d70f226 200 14.613 ms - 137

Submitting the same query, it raises an exception which is not handled and postman keeps waiting for response until Error: socket hang up is shown. This is the log:

Tue, 22 Sep 2020 11:59:12 GMT idm:api-authenticate  --> validate_token
Executing (default): SELECT `AuthToken`.`access_token`, `AuthToken`.`expires`, `AuthToken`.`valid`, `AuthToken`.`user_id`, `AuthToken`.`pep_proxy_id`, `User`.`id` AS `User.id`, `User`.`username` AS `User.username`, `User`.`email` AS `User.email`, `User`.`date_password` AS `User.date_password`, `User`.`enabled` AS `User.enabled`, `User`.`admin` AS `User.admin`, `PepProxy`.`id` AS `PepProxy.id` FROM `auth_token` AS `AuthToken` LEFT OUTER JOIN `user` AS `User` ON `AuthToken`.`user_id` = `User`.`id` LEFT OUTER JOIN `pep_proxy` AS `PepProxy` ON `AuthToken`.`pep_proxy_id` = `PepProxy`.`id` WHERE `AuthToken`.`access_token` = 'f8ce4ca3-a512-4c50-9f86-aebaa6a694fb';
Tue, 22 Sep 2020 11:59:12 GMT idm:api-users --> load_user
Executing (default): SELECT `id`, `username`, `email`, `enabled`, `admin`, `image`, `gravatar`, `date_password`, `description`, `website` FROM `user` AS `User` WHERE `User`.`id` = '9b038c24-035d-43bf-9e03-b3af5d70f226';
Tue, 22 Sep 2020 11:59:12 GMT idm:api-users --> update
Executing (default): SELECT `id`, `username`, `description`, `website`, `image`, `gravatar`, `email`, `salt`, `password`, `date_password`, `enabled`, `admin`, `starters_tour_ended`, `eidas_id`, `extra`, `scope` FROM `user` AS `User` WHERE `User`.`email` = 'alice@test.com';
Executing (default): 
Tue, 22 Sep 2020 11:59:12 GMT idm:api-users Error: SequelizeDatabaseError: Query was empty
(node:267) UnhandledPromiseRejectionWarning: TypeError: Cannot read property '0' of undefined
    at /opt/fiware-idm/controllers/api/users.js:330:25
(node:267) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 11)
PATCH /v1/users/9b038c24-035d-43bf-9e03-b3af5d70f226 - - ms - -