Skip to content

fix(slack): surface attachment access diagnostics#16206

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-aa28dba4
Apr 26, 2026
Merged

fix(slack): surface attachment access diagnostics#16206
teknium1 merged 1 commit into
mainfrom
hermes/hermes-aa28dba4

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Translate Slack attachment failures (missing_scope, invalid_auth, 401/403/404, HTML sign-in page) into actionable user-facing notices so the agent can tell the user what to fix, instead of logging a generic 'download failed' and going silent.

Changes

  • gateway/platforms/slack.py: two helpers — _describe_slack_api_error (SlackApiError response → text) and _describe_slack_download_failure (httpx/generic exception → text). Wired into the Slack Connect files.info path (from PR fix(slack): get files in Slack Connect channel #11111) and the image/audio/document download failure paths. When any of them translates an error, the notice is prepended to the inbound message text as [Slack attachment notice] so the agent sees it.
  • website/docs/user-guide/messaging/slack.md: files:read added to troubleshooting table + missing-scopes caution block mentions it.
  • Tests: direct-helper diagnostic tests + integration test that verifies a 403 download failure surfaces as a notice block in the message text.

Adjustment from original PR

Dropped _probe_slack_file_access_issue — the original PR added a proactive files.info call before every download attempt, even for healthy attachments. That's one extra Slack API round-trip per file per message. The post-failure translation path delivers the same user-facing diagnostic value without the per-message tax. (The helper method was also dead once the probe was removed, so _get_team_client went with it.)

Validation

tests/gateway/test_media_download_retry.py + tests/gateway/test_slack.py: 174 passed (3x green).

Credits

Closes #7015

Translate Slack attachment failures into actionable user-facing notices
instead of generic download errors. When a scope/auth/permission issue
breaks attachment processing, the user sees:

  [Slack attachment notice]
  - Slack attachment access failed for photo.jpg. Missing scope:
    files:read. Update the Slack app scopes/settings and reinstall
    the app to the workspace.

Two helpers do the translation:

  _describe_slack_api_error — handles SlackApiError responses
    (missing_scope, invalid_auth, file_not_found, access_denied, etc.)

  _describe_slack_download_failure — handles httpx.HTTPStatusError
    (401/403/404) and Slack-returns-HTML-sign-in fallbacks

Wired into three existing call sites:
 - the Slack Connect files.info path (PR #11111) so scope errors
   surface instead of being logged as generic "files.info failed"
 - the image, audio, and document download paths so 401/403 and
   HTML-body responses translate into actionable notices

Adjustment from original PR: dropped _probe_slack_file_access_issue,
the proactive pre-download files.info probe. It added one extra
Slack API call per attachment even on healthy ones, and overlapped
with the existing files.info call from PR #11111. The post-failure
translation path covers the same user-facing diagnostic value
without the per-message tax.

Also documents files:read scope more prominently in the Slack setup
guide and troubleshooting table.

Contributed back from https://github.com/xinbenlv/zn-hermes-agent.

Closes #7015.
Co-authored-by: xinbenlv <zzn+pa@zzn.im>
@teknium1 teknium1 merged commit 778fd18 into main Apr 26, 2026
11 of 12 checks passed
@teknium1 teknium1 deleted the hermes/hermes-aa28dba4 branch April 26, 2026 19:47
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists platform/slack Slack app adapter comp/gateway Gateway runner, session dispatch, delivery labels Apr 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists platform/slack Slack app adapter type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Repro: Slack file downloads still land as HTML sign-in pages in image_cache and break vision

3 participants