-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Description
As explained in the conversations.invite
Usage info
documentation including a single bad user ID in an conversations.invite
request will cause all the invites to fail. In such cases, the API response includes an errors
list containing user details as well as an error
explaining the reason for each respective invite failure (as shown below).
{
"ok": false,
"error": "user_not_found",
"errors": [
{
"user": "U111111",
"ok": false,
"error": "user_not_found"
},
{
"user": "U222222",
"ok": false,
"error": "cant_invite_self"
}
]
}
In the current state, the slack-go
module doesn't expose any of these user details in the error
value returned from the InviteUsersToConversation
client method. It just solely returns the error
value from the API response (ex: cant_invite
, already_in_channel
, etc):
Line 322 in abcbf2b
func (api *Client) InviteUsersToConversation(channelID string, users ...string) (*Channel, error) { |
This is problematic if you wish to implement a wrapper around the client which is resilient to such failures, as there is no easy way to determine which user IDs in your request caused the failure.
Potential Solution
One potential solution for this issue could be to use errors.Join
to include additional error
s with the relevant user details for each failure. I imagine there's some backwards compatibility concerns to consider for existing clients there, but nonetheless wanted to bring this issue to your attention. Thanks!