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

Cannot read property 'info' of undefined api.js:206 #45

Closed
maxkueng opened this issue Feb 25, 2015 · 0 comments · Fixed by #46
Closed

Cannot read property 'info' of undefined api.js:206 #45

maxkueng opened this issue Feb 25, 2015 · 0 comments · Fixed by #46

Comments

@maxkueng
Copy link
Contributor

The error handling seems a bit shaky. When doing an ask query (Semantic MediaWiki) the info variable is undefined even though data.query.results has results. This causes the response to fall through all the ifs all they way town to the else case even though there is actually no error. And then crashes on api.js:206 because data.error is undefined.

I think this part of the code should only run if there actually is an error i.e. typeof data.error !== 'undefined'.

This is my params object for client.api.call:

{
  action: 'ask',
  query: '[[Category:SIP Phone]]|?User'
};

and this is what the data variable contains:

{ query: 
   { printrequests: [ [Object], [Object] ],
     results: { 'SIP Phone 60': [Object], 'SIP Phone 61': [Object] },
     serializer: 'SMW\\Serializers\\QueryResultSerializer',
     version: 0.5,
     meta: { hash: 'd82a813f78da82e1d9b94acaee6e37c5', count: 2, offset: 0 } } }

and this is the complete error:

Debug: internal, implementation, error 
    TypeError: Cannot read property 'info' of undefined
    at Request._callback (/home/max/projects/xml-phonebook/node_modules/nodemw/lib/api.js:208:63)
    at Request.self.callback (/home/max/projects/xml-phonebook/node_modules/nodemw/node_modules/request/request.js:199:22)
    at Request.emit (events.js:98:17)
    at Request.<anonymous> (/home/max/projects/xml-phonebook/node_modules/nodemw/node_modules/request/request.js:1160:14)
    at Request.emit (events.js:117:20)
    at IncomingMessage.<anonymous> (/home/max/projects/xml-phonebook/node_modules/nodemw/node_modules/request/request.js:1111:12)
    at IncomingMessage.emit (events.js:117:20)
    at _stream_readable.js:944:16
    at process._tickDomainCallback (node.js:486:13)

TL;DR: It tries to report an error even though everything went fine.

macbre pushed a commit that referenced this issue Feb 25, 2015
Only show error if data.error has a value, make info optional, fixes #45
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

Successfully merging a pull request may close this issue.

1 participant