Im getting below error for a rule ::
6:56:47 PM:
{ “code”: 500, “error”: “Script generated an unhandled asynchronous exception.”, “details”: “TypeError: Cannot read properties of undefined (reading ‘roles’)”, “name”: “TypeError”, “message”: “Cannot read properties of undefined (reading ‘roles’)”, “stack”: “TypeError: Cannot read properties of undefined (reading ‘roles’)\n at _id (/data/io/node16/1431a683-fe24-4291-b240-a26e9ea6abfa/webtask.js:138:84)\n at fn (/data/sandbox/node16/node_modules/@a0/auth0-authz-rules-api/async.js:36:22)\n at /data/sandbox/node16/node_modules/@a0/auth0-authz-rules-api/async.js:73:20\n at processTicksAndRejections (node:internal/process/task_queues:78:11)” }
6:56:47 PM:
finished webtask request
6:56:47 PM:
Code generated an uncaught exception: TypeError: Cannot read properties of undefined (reading ‘roles’) at _id (/data/io/node16/1431a683-fe24-4291-b240-a26e9ea6abfa/webtask.js:138:84) at fn (/data/sandbox/node16/node_modules/@a0/auth0-authz-rules-api/async.js:36:22) at /data/sandbox/node16/node_modules/@a0/auth0-authz-rules-api/async.js:73:20 at processTicksAndRejections (node:internal/process/task_queues:78:11)
It Seems below function in my rule is giving error
request(reqOptions, function handleResponse(err, response, body) {
if (err) {
reject(err);
} else if (response.statusCode < 200 || response.statusCode >= 300) {
console.error(LOG_TAG, 'API call failed: ', body);
reject(new Error(body));
} else {
resolve(response.body);
}
}