Skip to content

Conversation

nlopes
Copy link
Collaborator

@nlopes nlopes commented Jun 7, 2025

There are a few methods in the Slack API that return an Errors field.

We've historically not captured this. It seems there are 4:

We do not support the last two in the library therefore I didn't even add at this stage.

This PR adds support for the first two in the list.

Fixes #1433.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for capturing and returning the errors field in Slack API responses for the /apps.manifest.create and /conversations.invite methods.

  • Introduces two new error structs (AppsManifestCreateResponseError, ConversationsInviteResponseError) and a union wrapper (SlackResponseErrors) with custom JSON (un)marshaling.
  • Extends SlackResponse and SlackErrorResponse to carry a slice of these errors.
  • Provides end-to-end tests and updates the example for handling conversation-invite errors.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
misc.go Added new error types, union type, and updated response structs
misc_test.go Added tests for marshaling/unmarshaling and top‐level errors
examples/conversations_invite/conversations_invite.go Updated example to iterate over the new Errors slice
Comments suppressed due to low confidence (3)

misc.go:45

  • [nitpick] The type name SlackResponseErrors is plural but represents a single error union. Consider renaming it to SlackResponseError for clarity, and adjust the slice field to []SlackResponseError.
type SlackResponseErrors struct {

misc_test.go:285

  • The test only checks for non-nil/len-zero Errors but doesn’t verify the actual contents of the parsed error structs. Add assertions to compare the fields (e.g. Pointer, Message, User) against the expected values.
if len(tt.expected.Errors) == 0 {

misc.go:126

  • [nitpick] The new Errors field on SlackErrorResponse lacks a comment explaining its purpose. Adding a doc comment will help users understand how to consume this slice of error unions.
Errors           []SlackResponseErrors

@nlopes nlopes force-pushed the nlopes-add-errors branch 2 times, most recently from 397b6d0 to b29beca Compare June 8, 2025 08:33
@nlopes nlopes force-pushed the nlopes-add-errors branch from b29beca to da97682 Compare June 8, 2025 15:19
@nlopes nlopes merged commit b42f029 into master Jun 8, 2025
7 checks passed
@nlopes nlopes deleted the nlopes-add-errors branch June 8, 2025 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Requesting the InviteUsersToConversation(..) to return user details on failed calls
1 participant