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

Invalid LTI consumer response may result in empty error #79

Open
SidneyNemzer opened this issue Jan 31, 2018 · 3 comments
Open

Invalid LTI consumer response may result in empty error #79

SidneyNemzer opened this issue Jan 31, 2018 · 3 comments

Comments

@SidneyNemzer
Copy link

SidneyNemzer commented Jan 31, 2018

Code

const lti = require('ims-lti')

const outcome = new lti.OutcomeService({
  consumer_key: 'key',
  consumer_secret: 'secret',
  // Note: localhost:3000 is a server that simply responseds with a status 200, empty body, to any request
  service_url: 'http://localhost:3000',
  source_did: 'sourcedid'
})

outcome.send_replace_result(1.0, (error, result) => {
  if (error) {
    console.error('Encountered an error while sending result:')
    console.error(error)
  }
})

Actual outcome

$ node test.js
Encountered an error while sending result:
{ [Error] message: undefined }

Expected outcome

Maybe a more helpful error message?

Cause

After debugging the program, it looks like the XML parser does not throw an error. But the code from the response is undefined (since the XML is empty), so the library assumes there was a non-success code and tries to throw an error using the message in the XML. But, again, there is nothing in the XML. So msg === undefined

callback new errors.OutcomeResponseError(msg), false

@lastmjs
Copy link

lastmjs commented Feb 5, 2018

Funny, I think I just started running into this same problem. So are the grades sent back correctly? What does the error actually indicate?

@SidneyNemzer
Copy link
Author

@lastmjs In my specific case, the LTI provider (which uses this library) sends the grades to the LTI consumer (which is another application that we control). The LTI consumer can extract the grade from the XML, but it doesn't bother with a valid LTI response (since both applications are only used internally). A valid response would be something like "got it, score recorded" (The actual response is detailed in the LTI specification of course).

But it's conceivable that you could get { [Error] message: undefined } by doing something else.

@lastmjs
Copy link

lastmjs commented Feb 6, 2018

Looks like my error was coming from the server returning a 500 response. A more helpful error message would have been very valuable

@SidneyNemzer SidneyNemzer changed the title When the LTI consumer returns an empty response to a send_result, 'undefined Error' is thrown An invalid LTI consumer response can cause an error with message: undefined Feb 7, 2018
@SidneyNemzer SidneyNemzer changed the title An invalid LTI consumer response can cause an error with message: undefined Invalid LTI consumer response may result in empty error Jun 18, 2018
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

No branches or pull requests

2 participants