fix(slack): harden attachment handling#16281
Merged
Merged
Conversation
Multiple overlapping Slack attachment improvements: 1. Upload retry with backoff on transient errors (429, 5xx, connection reset, rate_limited, service unavailable). New _is_retryable_upload_error helper covers three upload paths: _upload_file, send_video, send_document. Up to 3 attempts with 1.5s * attempt backoff. 2. Thread participation tracking: successful file uploads now add the thread_ts to _bot_message_ts, mirroring how text replies are tracked. This lets follow-up thread messages auto-trigger the bot (same engagement rules as replied threads). 3. Thread metadata preservation in the image redirect-guard fallback (send_image → send text fallback) and in two gateway.run.py send paths (image + document fallback calls). 4. HTML response rejection in _download_slack_file_bytes. Parallels the existing check in _download_slack_file. Guards against Slack returning a sign-in / redirect page as document bytes when scopes are missing, so the agent doesn't get HTML-as-a-PDF. 5. File lifecycle event acks (file_shared / file_created / file_change). These events arrive around snippet uploads. Acking them silences the slack_bolt 'Unhandled request' 404 warnings without changing behavior. 6. Post-loop message type classification so a mixed image+document upload classifies as PHOTO (or VOICE if no image), falling back to DOCUMENT. Previously, the per-file classification in the inbound loop could be overwritten unpredictably. 7. Expanded text-inject whitelist in inbound document handling to cover .csv, .json, .xml, .yaml, .yml, .toml, .ini, .cfg (up to 100KB) so snippets and config files are directly visible to the agent, not just cached as opaque uploads. Paired with new MIME entries in SUPPORTED_DOCUMENT_TYPES in base.py. Squashed from two commits in #11819 so the single commit carries the contributor's GitHub attribution (the original commits were authored under a local dev hostname).
19 tasks
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.
Consolidates several overlapping Slack attachment bugs that made file handling flaky.
Changes
_upload_file,send_video,send_documentnow do 3 attempts with 1.5s × attempt backoff on transient errors (429, 5xx, connection reset, rate_limited, service unavailable). New_is_retryable_upload_errorhelper.thread_tsto_bot_message_ts(same mechanism as text replies), so follow-up thread messages auto-trigger the bot instead of being ignored.send_image's SSRF redirect-guard text fallback and twogateway/run.pysend paths (image + document fallback) now passmetadatathrough, so thread replies land in the right thread._download_slack_file_bytes— parallels the existing check in_download_slack_file(images/audio). Guards against Slack returning a sign-in/redirect page as document bytes when scopes are missing, so the agent doesn't get HTML-as-PDF cached.file_shared/file_created/file_changeevents now have no-op handlers to silence bolt 'Unhandled request' 404 warnings around snippet uploads..csv,.json,.xml,.yaml,.yml,.toml,.ini,.cfgare now injected directly into the prompt (up to 100KB) instead of being cached as opaque uploads. Paired with matching MIME entries inSUPPORTED_DOCUMENT_TYPES(base.py).Validation
tests/gateway/test_slack.py+test_slack_mention.py+test_slack_approval_buttons.py+test_media_download_retry.py+test_session.py+test_channel_directory.py: 354 passed.Credits
Closes #11819