openclaw/extensions/slack
martingarramon 150053bc86
fix(slack): route stream-fallback delivery through chunked sender (follow-up to #70370) (#71124)
* fix(slack): route stream-fallback delivery through chunked sender

deliverPendingStreamFallback was calling chat.postMessage directly for
err.pendingText, which bypasses the chunked reply path used everywhere
else. For Slack Connect cases where appendSlackStream throws
SlackStreamNotDeliveredError with a large pending buffer, the single
raw post could fail (msg_too_long) and drop the unsent tail.

Two changes:

1. deliverPendingStreamFallback now routes through deliverReplies so
   long pendingText is chunked by the normal sender and the fallback
   honors the configured replyToMode / identity.

2. The non-benign streaming-error branch in deliverWithStreaming now
   clears the session via markSlackStreamFallbackDelivered before
   falling back to deliverNormally. Without this, pendingText stays
   populated and the post-loop finalize (stopSlackStream →
   SlackStreamNotDeliveredError → fallback) re-posts the same chunk
   that deliverNormally already sent.

Addresses the three Codex P1 findings on #70370 about bypassing the
chunked sender, and the related "avoid reposting buffered text after
append fallback" P1 about duplicate delivery. Tests updated to assert
deliverReplies routing (instead of raw postMessage) and a new case
covers the non-benign-error dedup.

Follow-up to #70370.

* fix(slack): preserve pending buffered text on non-benign stream errors

Address Codex P1 on #71124: `markSlackStreamFallbackDelivered` was
clearing `pendingText` before `deliverNormally` ran, so any earlier
buffered chunk was lost. E.g. chunk A buffered in the SDK, then
appending chunk B throws a generic network error → previous fix
dropped A+B and only sent B via `deliverNormally`, silently truncating
the final reply.

Route the full buffered `pendingText` through
`deliverPendingStreamFallback` with a synthetic
`SlackStreamNotDeliveredError`, then skip `deliverNormally` entirely
(pendingText already contains this payload's text, per
`appendSlackStream` accumulating before throw). If the chunked
fallback fails, fall back to `deliverNormally` so at least the current
payload lands.

Test updated to assert the full pendingText ("first buffered\nsecond
payload") gets routed through the chunked sender, not the
chunk-B-only partial send.

* fix(slack): harden stream fallback docs and chunking test (#71124)

---------

Co-authored-by: Peter Steinberger <steipete@gmail.com>
2026-04-24 22:50:18 +01:00
..
src fix(slack): route stream-fallback delivery through chunked sender (follow-up to #70370) (#71124) 2026-04-24 22:50:18 +01:00
account-inspect-api.ts perf: speed up security audit test imports 2026-04-16 21:54:13 +01:00
api.ts refactor: clean bundled channel bootstrap boundaries 2026-04-05 18:18:59 +01:00
channel-config-api.ts
channel-entry.ts perf(slack): narrow runtime-setter + lazy-load 4 modules + narrow 2 SDK surfaces (#69317) 2026-04-22 16:42:43 +10:00
channel-plugin-api.ts test: speed up slack setup entry tests 2026-04-07 19:59:46 +01:00
config-api.ts refactor(extensions): add channel-owned config schema seams 2026-04-04 05:31:11 +01:00
configured-state.ts refactor: add metadata-first channel configured-state probes 2026-04-06 01:02:45 +01:00
contract-api.ts tests(contracts): use contract-api for Slack and Discord directories (#65280) 2026-04-12 18:54:58 +08:00
directory-contract-api.ts test: slim channel directory contracts 2026-04-18 01:36:15 +01:00
doctor-contract-api.ts fix(slack): isolate doctor contract API (#63192) 2026-04-13 17:33:49 -07:00
http-routes-api.ts perf(slack): narrow runtime-setter + lazy-load 4 modules + narrow 2 SDK surfaces (#69317) 2026-04-22 16:42:43 +10:00
inbound-contract-test-api.ts test: slim channel contract hotspots 2026-04-18 01:36:33 +01:00
index.test.ts test(extensions): dedupe bundled entry smoke tests 2026-04-12 03:09:18 +01:00
index.ts perf(slack): narrow runtime-setter + lazy-load 4 modules + narrow 2 SDK surfaces (#69317) 2026-04-22 16:42:43 +10:00
interactive-replies-api.ts fix(tests): narrow bundled plugin test seams 2026-04-06 23:35:07 +01:00
message-tool-api.ts Tests: fast-path Slack message tool discovery 2026-04-17 02:00:26 -04:00
openclaw.plugin.json refactor: resolve channel env vars from plugin manifests 2026-04-06 19:53:27 +01:00
outbound-payload-test-api.ts test: slim channel contract hotspots 2026-04-18 01:36:33 +01:00
package.json chore(deps): update workspace dependencies 2026-04-24 16:55:08 +01:00
runtime-api.ts refactor: clean bundled channel bootstrap boundaries 2026-04-05 18:18:59 +01:00
runtime-setter-api.ts perf(slack): narrow runtime-setter + lazy-load 4 modules + narrow 2 SDK surfaces (#69317) 2026-04-22 16:42:43 +10:00
secret-contract-api.ts fix: repair bundled channel secret sidecars 2026-04-08 04:56:58 +01:00
security-contract-api.ts fix(tests): narrow bundled plugin test seams 2026-04-06 23:35:07 +01:00
setup-entry.ts fix: repair bundled channel secret sidecars 2026-04-08 04:56:58 +01:00
setup-plugin-api.ts test: speed up slack setup entry tests 2026-04-07 19:59:46 +01:00
test-api.ts fix(plugins): keep test helpers out of contract barrels (#63311) 2026-04-08 22:59:05 +01:00
tsconfig.json chore(plugins): bulk add package boundary tsconfig rollout 2026-04-07 08:48:23 +01:00