Skip to content

fix(slack): read real SDK responses instead of gating on isinstance dict (salvage #74658) - #85463

Merged
teknium1 merged 2 commits into
mainfrom
salv-74658
Aug 13, 2026
Merged

fix(slack): read real SDK responses instead of gating on isinstance dict (salvage #74658)#85463
teknium1 merged 2 commits into
mainfrom
salv-74658

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

Slack adapter now reads real slack_sdk response objects — user name resolution, bot detection, ephemeral send confirmation, and thread ts reads all work again. Salvage of #74658 by @nikitaBarkov onto current main, authorship preserved.

Root cause: commits from #69483/#70196/#69479 added isinstance(resp, dict) gates on Web API responses, but SlackResponse/AsyncSlackResponse are not dict subclasses — every gate was always False at runtime while dict-injecting tests stayed green.

Changes

  • plugins/platforms/slack/adapter.py: new _slack_response_payload() normalizer (dict passthrough → .data if dict → {}), routed through all 8 gated call sites — whole-class fix
  • tests/gateway/test_slack_sdk_response.py: 18 tests parametrized over a stand-in AND a real AsyncSlackResponse, including the handoff-thread seed-ts and standalone media-send paths flagged in review

Validation

Before After
users.info result discarded, raw ID cached forever name resolved
bot detection always False works
ephemeral send reported as failure confirmed
targeted tests 18/18 pass

Infographic

Slack adapter SDK response fix

nikitaBarkov and others added 2 commits August 13, 2026 10:19
Slack Web API calls return `SlackResponse`/`AsyncSlackResponse`, which are
mapping-like but not `dict` subclasses, so every `isinstance(resp, dict)`
gate took its "unexpected shape" branch at runtime: user and channel names
collapsed to raw IDs, every user resolved as a non-bot (defeating the
allow_bots loop guard), ephemeral replies were reported as failures, and
uploads/caption fallbacks lost their message_id.

Normalize responses through a single `_slack_response_payload()` helper
(dict passes through, SDK response yields `.data`, anything else yields
`{}` so callers keep their fallbacks) and use it at every call site.

Existing Slack tests injected plain dicts, which is why the defect was
invisible; the new tests run each behavioral case against a real
`AsyncSlackResponse` as well.
…se reads

Review on #74658 flagged that the response-shape suite exercised identity,
ephemeral and upload paths but left two changed call sites untested:

- create_handoff_thread's seed-message ts (adapter.py:2262), which anchors
  every subsequent handoff send onto the thread;
- the standalone media branch's chat_postMessage reads (adapter.py:8721 text
  post, :8749 caption fallback), where an SDK-shaped reply used to drop the
  ts and report a caption-only delivery as 'nothing deliverable'.

Both new cases run against the hand-rolled stand-in and the real
AsyncSlackResponse. Verified they fail against the pre-fix adapter.

Co-authored-by: Junie <junie@jetbrains.com>
@github-actions

github-actions Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

૮ >ﻌ< ა ci review

ran on 8c6a0fd — test(slack): cover handoff-thread ts and standalone media se

⚠️ Warnings

OSV vulnerability scan · View job

5 known vulnerabilities found in pinned dependencies.

How to fix:

Review the findings in the Security tab. Update the affected dependencies if a patched version is available.


debug info

CI timings

CI timings · View report · View job

Wall time 3m20s vs 7m10s (-53.5%). 12 job(s) slower, 10 faster, 2 unchanged.

  • Python tests / Run tests slice 1/12: +35.0s
  • Python tests / Run tests slice 7/12: +30.0s
  • Python tests / Run tests slice 4/12: -28.0s
  • Python tests / Run tests slice 9/12: -23.0s
  • Python tests / Run tests slice 11/12: +13.0s

@alt-glitch alt-glitch added type/bug Something isn't working comp/plugins Plugin system and bundled plugins platform/slack Slack app adapter P3 Low — cosmetic, nice to have labels Aug 13, 2026
@teknium1
teknium1 merged commit 24ba866 into main Aug 13, 2026
48 checks passed
@teknium1
teknium1 deleted the salv-74658 branch August 13, 2026 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have platform/slack Slack app adapter type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants