Dialog handler must return error array inside object
Description
The Readme indicates that a dialog handler should return an array of errors matching the structure in the API documents, but in fact, the handler must return an object with an errors property which contains the array.
As described in Readme: " Your app returns a list of errors (or a Promise for a list of errors) from the handler. "
which seems to imply:
return [{name:'username', error:'invalid username'}]
However, this is the only way I can get it working:
return {errors: [{name:'username', error:'invalid username'}]}
I'm not sure if this is an error in the documentation or the implementation.
What type of issue is this? (place an x in one of the [ ])
- [x] bug
- [ ] enhancement (feature request)
- [ ] question
- [x] documentation related
- [ ] testing related
- [ ] discussion
Requirements
- [ ] I've read and understood the Contributing guidelines and have done my best effort to follow them.
- [ ] I've read and agree to the Code of Conduct.
- [ ] I've searched for any related issues and avoided creating a duplicate issue.
Bug Report
Filling out the following details about bugs will help us solve your issue sooner.
Reproducible in:
@slack/interactive-messages version: 1.0.2 node version: 8.12 OS version(s): macOS 10.14.2
Steps to reproduce:
- return an array from dialog action handler
Expected result:
Dialog displays errors from array on form fields.
Actual result:
Dialog displays "We had some trouble connecting" error, with "Retry" option.
Attachments:
ngrok response log when returning array:
`HTTP/1.1 200 OK X-Powered-By: Express X-Slack-Powered-By: @slack:interactive-messages/1.0.2 darwin/18.2.0 node/8.12.0 Content-Type: application/json Date: Wed, 09 Jan 2019 18:31:02 GMT Connection: keep-alive Content-Length: 139
[{"name":"duration","error":"Duration must be greater than 0 hours"}]`
ngrok response log when returning object with array property: `HTTP/1.1 200 OK X-Powered-By: Express X-Slack-Powered-By: @slack:interactive-messages/1.0.2 darwin/18.2.0 node/8.12.0 Content-Type: application/json Date: Wed, 09 Jan 2019 18:33:13 GMT Connection: keep-alive Content-Length: 150
{"errors":[{"name":"duration","error":"Duration must be greater than 0 hours"}]}`
@lucid-kyle you're totally right. thanks for catching this mistake.
I think the paragraph and code example should state that the errors would be in the property of an object. It would also be helpful to include a link to the input validation section of the platform documentation.
Addressed with #78