Skip to content
This repository has been archived by the owner on Aug 5, 2024. It is now read-only.

nexmo insight:standard throws exception with SMS Shortcode #43

Closed
leggetter opened this issue May 17, 2016 · 8 comments
Closed

nexmo insight:standard throws exception with SMS Shortcode #43

leggetter opened this issue May 17, 2016 · 8 comments
Labels

Comments

@leggetter
Copy link
Contributor

Steps to reproduce

› nexmo insight:standard {Long Virtual Number} e.g. SMS Shortcode
This operation will charge your account.

Please type "confirm" to continue: confirm

/usr/local/lib/node_modules/nexmo-cli/distribution/response.js:185
      this.emitter.list(response.international_format_number + ' | ' + response.country_code + ' | ' + response.current_carrier.name, response);
                                                                                                                               ^

TypeError: Cannot read property 'name' of undefined
    at Response.insightStandard (/usr/local/lib/node_modules/nexmo-cli/distribution/response.js:185:128)
    at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/nexmo-cli/node_modules/easynexmo/lib/nexmo.js:257:19)
    at emitNone (events.js:85:20)
    at IncomingMessage.emit (events.js:179:7)
    at endReadableNT (_stream_readable.js:913:12)
    at _combinedTickCallback (node.js:377:13)
    at process._tickCallback (node.js:401:11)

Expected behavior

I would not expect an exception.

Actual behavior

As above, we get an exception logged to the console.

System configuration

Node version: v5.7.1

NPM version: 3.6.0

Operating system: OSX 10.11.4

@leggetter leggetter added the bug label May 17, 2016
@cbetta
Copy link
Contributor

cbetta commented May 17, 2016

@leggetter as I don't have a shortnumber, can you run with --debug and post the API result?

@cbetta
Copy link
Contributor

cbetta commented May 17, 2016

Also does the API support this?

@leggetter
Copy link
Contributor Author

leggetter commented May 17, 2016

› nexmo insight:standard NUMBER --debug
This operation will charge your account.

Please type "confirm" to continue: confirm

{ host: 'api.nexmo.com',
  port: 443,
  path: '/number/lookup/json?number=NUMBER&api_key=KEY&api_secret=SECRET',
  method: 'GET',
  headers:
   { 'Content-Type': 'application/x-www-form-urlencoded',
     accept: 'application/json' } }
response ended
Validator.response() - Error:
null
Validator.response() - Response:
{ status: 3,
  status_message: 'Invalid request :: Not valid number format detected [ 45************ ]' }
End Validator.response()
/usr/local/lib/node_modules/nexmo-cli/distribution/response.js:185
      this.emitter.list(response.international_format_number + ' | ' + response.country_code + ' | ' + response.current_carrier.name, response);
                                                                                                                               ^

TypeError: Cannot read property 'name' of undefined
    at Response.insightStandard (/usr/local/lib/node_modules/nexmo-cli/distribution/response.js:185:128)
    at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/nexmo-cli/node_modules/easynexmo/lib/nexmo.js:257:19)
    at emitNone (events.js:85:20)
    at IncomingMessage.emit (events.js:179:7)
    at endReadableNT (_stream_readable.js:913:12)
    at _combinedTickCallback (node.js:377:13)
    at process._tickCallback (node.js:401:11)

@cbetta - Will DM you the number.

@cbetta cbetta self-assigned this May 17, 2016
@cbetta
Copy link
Contributor

cbetta commented May 17, 2016

@leggetter the number is in the debug...

@cbetta cbetta removed their assignment May 17, 2016
@sammachin
Copy link
Contributor

@leggetter Were you trying to run number insight against an SMS shortcode? (eg 89101) These type of numbers are country and sometimes even carrier specific so aren't really 'phone numbers' in the sense of the e.164 numbering plan.
Number Insight only works against e.164 numbers that you can dial/sms from ANY phone.

Also FYI LVN's are a term for the e.164 numbers that Nexmo sells for Voice and or SMS

@leggetter
Copy link
Contributor Author

{ status: 3,
  status_message: 'Invalid request :: Not valid number format detected [ NUMBER ]' }

It wasn't a short code.
456***********

@sammachin
Copy link
Contributor

Ok this looks to be a bug with the nexmo-node library when making a request for an invalid number to the insight standard API it works when requesting insight basic (although exposing the error could be better)

BASIC:

{ host: 'api.nexmo.com',
  port: 443,
  path: '/number/format/json?number=441233444341324&api_key=XXX&api_secret=XXX',
  method: 'GET',
  headers: 
   { 'Content-Type': 'application/x-www-form-urlencoded',
     accept: 'application/json' } }
response ended
Validator.response() - Error: 
null
Validator.response() - Response: 
{ status: 3,
  status_message: 'Invalid request :: Not valid number format detected [ 441233444341324 ]' }

STANDARD:

{ host: 'api.nexmo.com',
  port: 443,
  path: '/number/lookup/json?number=441233444341324&api_key=XXX&api_secret=XXX',
  method: 'GET',
  headers: 
   { 'Content-Type': 'application/x-www-form-urlencoded',
     accept: 'application/json' } }
response ended
Validator.response() - Error: 
null
Validator.response() - Response: 
{ status: 3,
  status_message: 'Invalid request :: Not valid number format detected [ 441233444341324 ]' }
End Validator.response()
/usr/local/lib/node_modules/nexmo-cli/distribution/response.js:185
      this.emitter.list(response.international_format_number + ' | ' + response.country_code + ' | ' + response.current_carrier.name, response);
                                                                                                                               ^

TypeError: Cannot read property 'name' of undefined
    at Response.insightStandard (/usr/local/lib/node_modules/nexmo-cli/distribution/response.js:185:128)
    at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/nexmo-cli/node_modules/easynexmo/lib/nexmo.js:257:19)
    at emitNone (events.js:72:20)
    at IncomingMessage.emit (events.js:166:7)
    at endReadableNT (_stream_readable.js:913:12)
    at nextTickCallbackWith2Args (node.js:442:9)
    at process._tickCallback (node.js:356:17)

@sammachin
Copy link
Contributor

So having discussed this with @cbetta its not a nexmo-node issue its the CLI not handling the error nicely, so this needs to be fixed in the CLI.

If it seens a status other than 0 returned it should print the contents of the status_message to the screen, this should work in both normal and verbose modes

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

No branches or pull requests

3 participants