-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add response metadata to slack response #772
Add response metadata to slack response #772
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @alyosha. Thank you for this. Is godebug
actually used? I can't see any references to it other than in the modules and vendor list. If it isn't used (could be that I'm missing it), could you remove it please. Then I can get this merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to @ollieparsley's comments, I commented a bit :)
misc.go
Outdated
Error string `json:"error"` | ||
Ok bool `json:"ok"` | ||
Error string `json:"error"` | ||
ResponseMetadata map[string]interface{} `json:"response_metadata"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you can use struct { Message []string }
as the type of response_metadata
instead of map[string]interface{}
.
e.g. official Java Implementation: https://github.com/slackapi/java-slack-sdk/blob/main/slack-api-model/src/main/java/com/slack/api/model/ResponseMetadata.java
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hey @kanata2 thanks for your feedback! I would be open to using a struct instead of a map here, will update
hey @ollieparsley it's used in test but this is purely a personal preference (just wanted to check all fields match in the expected/received struct, where before only a few were being checked) I will drop in lieu of reflect though, just to avoid introducing new deps 👍 |
6d8aacd
to
b0eeb26
Compare
Thanks again for the reviews and sorry for the delay in updating 👋 I made the move to use a struct rather than map as @kanata2 suggested, but I noticed there are already multiple I confirmed the behavior using a personal project and updated the PR description with an example of what the metadata looks like following these changes |
Fixes #805 Would love to see this merge, otherwise errors are not debuggable :) |
Summary of Changes
The Web API response represented by the
SlackResponse
struct can contain an additional JSON field"response_metadata"
in such cases as block validation failure, etc. It would be helpful to include the field in the struct so that these extra descriptors can be returned in existing models likeViewResponse
when something goes wrong.Example
Below are two examples of what the
ViewResponse
looks like when dumped before/after the addition.Before
After