joshbirk / passport-forcedotcom

A passport.js oauth strategy for ForceDotCom/DatabaseDotCom
BSD 3-Clause "New" or "Revised" License
37 stars 30 forks source link

The "url" argument must be of type string. Received undefined. #28

Open ShreyaNimma-at opened 1 year ago

ShreyaNimma-at commented 1 year ago

We noticed the following error occur in this library, specifically at this line of code. It's not clear to me under what circumstances rawProfile.urls.users is undefined but it's a fatal error. It is also hard to catch this error outside of this library because this line of code is within an asynchronous callback and handling errors within asynchronous callbacks is tricky in Node. It would be nice to handle this error in-place so that it doesn't terminate the calling process.

TypeError: The "url" argument must be of type string. Received undefined
    at new NodeError (node:internal/errors:387:5)
    at validateString (node:internal/validators:121:11)
    at Url.parse (node:url:168:3)
    at Object.urlParse [as parse] (node:url:155:13)
    at node_modules/.store/passport-forcedotcom-npm-0.1.5-6bd2f32086/node_modules/passport-forcedotcom/lib/passport-forcedotcom/strategy.js:100:24
    at node_modules/.store/passport-forcedotcom-npm-0.1.5-6bd2f32086/node_modules/passport-forcedotcom/lib/passport-forcedotcom/strategy.js:133:5
    at passBackControl (node_modules/.store/oauth-npm-0.9.15-a6aae972bc/node_modules/oauth/lib/oauth2.js:134:9)
    at IncomingMessage.<anonymous> (node_modules/.store/oauth-npm-0.9.15-a6aae972bc/node_modules/oauth/lib/oauth2.js:157:7)
    at IncomingMessage.emit (node:events:525:35)
    at IncomingMessage.emit (node:domain:552:15)
    at endReadableNT (node:internal/streams/readable:1358:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
trwinquist commented 9 months ago

Running into this error as well, and would like to echo the sentiment that this error is really hard to catch and trap outside of the library because of the way its used. Would it be possible to do something like simply skip the photo url if the rawProfile.urls.users is undefined? something like this. Would be happy to open a PR for this to solve uncaught error.

trwinquist commented 9 months ago

@joshbirk let me know if the linked PR seems like an alright way to fix this!

trwinquist commented 9 months ago

@joshbirk could you publish the new version to npm so we can bump the version that we're using?

kukidon-dev commented 9 months ago

The same issue. @joshbirk please, publish the new version to the npm with mentioned fix. We would appreciate.

trwinquist commented 9 months ago

version 0.2.1 has been published

kukidon-dev commented 9 months ago

Thank you!

trwinquist commented 7 months ago

Just want to add a small note here about when this seemed to happen. It appears that free/demo salesforce accounts do not have this parameter available on the user profile while paid accounts do