Repository navigation
fix(slack): fail collection on ok:false API responses - #9440
Open
ShivamSharma43 wants to merge 1 commit into
Open
ShivamSharma43 wants to merge 1 commit into
ShivamSharma43 wants to merge 1 commit into
Conversation
Slack answers most failed Web API calls with HTTP 200 and
{"ok": false, "error": "..."}. The channel, message and thread
collectors only read the data arrays, so an error such as
not_in_channel or missing_scope was treated as an empty page and the
pipeline succeeded with no data. Return an error with Slack's error code
instead. conversations.replies' thread_not_found is skipped, so a parent
message deleted between subtasks does not fail the whole collection.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Slack collectors ignore failed API calls, so a pipeline can succeed without collecting anything.
Slack answers most failed Web API calls with HTTP 200 and a body like
{"ok": false, "error": "not_in_channel"}(alsochannel_not_found,missing_scope,invalid_auth, ...). The response parsers ofcollectChannel(conversations.list),collectChannelMessage(conversations.history) andcollectThread(conversations.replies) only read thechannels/messagesarray, which is missing in an error body. The error is treated as an empty page: nothing is stored and the subtask succeeds. For example, when the Slack app is not a member of the channel chosen as the scope, every sync finishes successfully with no messages, and nothing tells the user why.Changes:
apimodels/im_result.go: the three result types also decode Slack'serrorfield.tasks/api_client.go: newcheckSlackApiResultreturnsslack <method> error: <error code>whenokis false.tasks/*_collector.go: the response parsers are moved into named functions (parseChannelResponse,parseChannelMessageResponse,parseThreadResponse) that call it, so the subtask fails with Slack's error code.listSlackRemoteScopesinapi/remote_api.goalready checksokthe same way for the scope picker.parseThreadResponseskipsthread_not_found(the parent message was deleted after the messages were collected) instead of failing the whole collection.GetNextPageCustomDataonly runs after the parser succeeded, so it needs no change.Does this close any open issues?
No issue is open for this. The bug is described above.
Screenshots
N/A
Other Information
response_parser_test.gochecks each parser with anok: truebody, anok: falsebody with and without an error code, and thethread_not_foundskip. WithcheckSlackApiResultdisabled, theok: falsecases fail.go test ./plugins/slack/...,go vet ./plugins/slack/...,gofmtandgolangci-lint run ./plugins/slack/...are clean. The plugin has no e2e tests.pr-type/bug-fix.Co-Authored-By:trailer.🤖 Generated with Claude Code