Skip to content

[Bug]: Slack provider doesn't reliably reload after channels.slack.botToken rotation (cached singleAuthorization) #80346

Closed as not planned

Description

@adapepper

Summary

After a Slack bot token rotation (edited in panel/config and persisted to ~/.openclaw/openclaw.json), the running Slack provider does not reliably reload the new token. The cached token in @slack/bolt's singleAuthorization keeps returning the old value, so every inbound event fails auth.test with invalid_auth. Symptom looks like "Slack integration broken" — messages stop routing — even though the new token on disk is valid.

Environment

  • OpenClaw 2026.5.6 (downstream managed instance, single container)
  • Channel: Slack (Bolt)

Repro

  1. Running gateway with a working Slack channel.
  2. Edit channels.slack.botToken in ~/.openclaw/openclaw.json (or via panel "save Slack config") to a freshly rotated token.
  3. Observe gateway logs around the edit timestamp.

Expected

[gateway/channels] restarting slack channel fires within the inotify debounce window, the App instance is rebuilt with the new token, and auth.test succeeds on the next inbound event.

Actual

  • Earlier edits in the same session (e.g. 14:34, 14:54 UTC on 2026-05-10) did trigger the restart line.
  • A later edit (15:35 UTC, same file, same key) did not trigger any restart line — the old token stayed cached in memory.
  • All inbound events from then on hit invalid_auth against auth.test, even though a direct auth.test against the on-disk token succeeded.
  • Workaround: docker restart <container>. After restart, Slack reconnected clean and stayed healthy.

Suspected cause

  • @slack/bolt singleAuthorization caches authorization.botToken per App instance. The provider reuses the existing App rather than tearing it down and rebuilding when only the bot token changes.
  • The inotify-based config watcher / config.patch path appears to debounce or skip the restart for some edit shapes (token-only change while other fields are unchanged).

Asks (either fixes the user-visible bug)

  1. Reliable channel restart on token change. Gateway should always emit [gateway/channels] restarting slack channel when channels.slack.botToken (or appToken) actually changes on disk, regardless of the surrounding edit shape.
  2. Or: the panel's "save Slack config" path should explicitly call gateway/channels restart-slack after persisting, so we don't depend on the watcher firing.

Notes / not this bug

  • This is not "multiple Slack sessions" or "message routing splitting." A user-side hypothesis ("OpenClaw is creating multiple Slack sessions per user") was reported but did not match the logs. The actual symptom is a single stale App instance holding a cached token.
  • Loosely related (different code path, already merged): fix(gateway): restart channels after secret reload #70720 fix(gateway): restart channels after secret reload — that fix targets SecretRef refresh; this issue is about plain token-string rotation in channels.slack.botToken not triggering a restart.

Activity

  1. clawsweeper commented on May 10, 2026

    @clawsweeper
    Contributor

    Thanks for the report. I checked current main, but this shell is missing enough reproduction detail to verify a current bug.

    Close as stale insufficient information: current code covers both direct config writers and file-watcher reloads, but the remaining managed-container boundary has no current-version reproduction or diagnostic trace despite the maintainer request.

    Review details

    Best possible solution:

    Keep the generic Gateway reload path; reopen with a current container reproduction that identifies whether the save bypassed the write listener or the watcher failed to observe the persisted file.

    Do we have a high-confidence way to reproduce the issue?

    No. Direct token edits were reported to restart reliably on main, while no current container or Control UI trace establishes the claimed missed boundary.

    Is this the best way to solve the issue?

    Unclear. The generic reload path is the right owner, but a safe further change cannot be selected without proving whether the writer notification or filesystem watcher is failing.

    Security review:

    Security review: This is issue triage without a proposed patch; no new security or supply-chain change was reviewed.

    AGENTS.md: found and applied where relevant.

    What I checked:

    • Slack restart contract: Slack registers all channels.slack changes as reload-sensitive, and the generic planner maps channel prefixes to whole-channel restart actions. (extensions/slack/src/channel.setup.ts:48, 306c923e3d19)
    • Control-plane and watcher paths: The reloader consumes in-process writes immediately, preserves pending restart intent across watcher echoes, and recreates/degrades failed watchers before declaring hot reload disabled. (src/gateway/config-reload.ts:1088, 306c923e3d19)
    • Channel lifecycle: A planned whole-channel restart logs the restart, stops the channel, then starts it again, replacing the in-memory Slack application instance. (src/gateway/server-reload-channel-restart.ts:160, 306c923e3d19)
    • Regression coverage: Current tests cover retrying a failed in-process write with the same persisted hash and watcher replacement followed by reconciliation. (src/gateway/config-reload.test.ts:3037, 306c923e3d19)
    • Relevant history: The restart-intent/coalescing path was specifically changed by the July 28 gateway fix, after the reported May version and before this review. (src/gateway/config-reload.ts:1107, 1eb038bd43e9)
    • Release provenance: The supplied latest release is v2026.7.1-2; the local tag containment check reports no release tag containing the later coalesced-write fix, so the remaining conclusion is based on current-main source rather than a shipped container reproduction. (1eb038bd43e9)

    Likely related people:

    • steipete: Current source attribution and the July watcher-recovery history connect this person to the reload and recovery path; they also requested the missing container evidence in the discussion. (role: recent gateway lifecycle contributor; confidence: high; commits: a040f10e85aa, 72283e440e07; files: src/gateway/config-reload.ts, src/gateway/server-reload-managed.ts)
    • metaforismo: Authored the history entry explicitly preserving restart intent across coalesced config writes, the closest addressed failure mode. (role: introduced coalesced-write restart handling; confidence: high; commits: 1eb038bd43e9; files: src/gateway/config-reload.ts, src/gateway/config-reload.test.ts)

    Codex review notes: model internal, reasoning high; reviewed against 306c923e3d19.

  2. tmimmanuel commented on May 10, 2026

    @tmimmanuel
    Contributor

    @adapepper — tried to reproduce against current main (1c1136902b); the restart path fires reliably on every channels.slack.botToken edit I tested. Posting the run in case the gap is environmental.

    Setup

    • Built from main at 1c1136902b, run as pnpm openclaw gateway (embedded, port 18789, loopback) on Ubuntu 24.04 / Node 22.22, not in a container
    • Real ~/.openclaw/openclaw.json with Slack channel attached
    • Edits done atomically (temp file + os.rename) under inotify; backup taken before, restored after

    Static analysis — wiring looks correct on main

    • extensions/slack/src/shared.ts:124 and channel.setup.ts:73 declare reload: { configPrefixes: ["channels.slack"] }
    • src/gateway/config-reload-plan.ts:152-160 lifts that prefix into a restart-channel:slack rule
    • Any changed path matching channels.slack.* (including channels.slack.botToken) populates plan.restartChannels
    • src/gateway/server-reload-handlers.ts:367 logs restarting slack channel and rebuilds the channel

    So in theory a botToken change must land in restartChannels.

    Live test — 14 edits, 11 restarts (matches expected coalescing)

    Sequential edits with varying gaps (3-10 s):

    edit 1 (3s gap):  ✓ restart fired (+750ms)
    edit 2 (4s gap):  ✓ restart fired (+760ms)
    edit 3 (5s gap):  ✓ restart fired (+770ms)
    edit 4 (6s gap):  ✓ restart fired (+760ms)
    edit 5 (7s gap):  ✓ restart fired (+740ms)
    edit 6 (8s gap):  ✓ restart fired (+730ms)
    edit 7 (9s gap):  ✓ restart fired (+725ms)
    edit 8 (10s gap): ✓ restart fired (+695ms)
    fired: 8/8, missed: 0/8
    

    Debounce edge — 5 burst edits 200 ms apart:

    burst edit 1 at 17:54:09.176
    burst edit 2 at 17:54:09.434
    burst edit 3 at 17:54:09.698
    burst edit 4 at 17:54:09.964
    burst edit 5 at 17:54:10.205
    burst restart count: 1   ← coalesced; end-state token wins
    

    Solo follow-up after burst: 1 edit → 1 restart (watcher still alive).

    Total: 14 edits → 11 restart events, matching expected debounce. No misses.

    Possible reasons your environment hits it and mine doesn't

    1. Container inotify — chokidar over overlayfs / Docker bind mounts is known to drop events, especially when the host writes through a bind mount. Sandpaw sandpaw-go-yard is a managed container; this is a strong candidate.
    2. Gateway's own internal-write hash de-dupe — if your panel's "save Slack config" goes through the gateway's config.patch RPC (rather than a direct file write), the gateway compares the resulting on-disk hash against its initialInternalWriteHash to suppress reload-plan execution on writes it triggered itself. If the panel write is being mis-attributed to an internal write, the watcher would see the change but the reload would noop. Worth checking via the panel's network tab whether it calls config.patch or writes the file directly.
    3. Long-session state — your miss landed at 15:35 after edits at 14:34 and 14:54. If a chokidar watcher gets stuck after ~1 h (overlayfs idle close, etc.), my 2-minute stress wouldn't see it.
  3. openclaw-barnacle commented on Jun 1, 2026

    @openclaw-barnacle

    This issue has been automatically marked as stale due to inactivity.
    Please add updates or it will be closed.

  4. added
    P2Normal backlog priority with limited blast radius.
    impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.
    impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.
    issue-rating: 🦪 silver shellfishThin issue quality; more reproduction proof or environment detail is needed.
    clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.
    clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.
    on Jun 1, 2026
  5. added
    issue-rating: 🦐 gold shrimpDecent issue quality, but reproduction details are still incomplete.
    clawsweeper:needs-infoClawSweeper needs more reporter information before it can verify this issue.
    clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.
    and removed
    issue-rating: 🦪 silver shellfishThin issue quality; more reproduction proof or environment detail is needed.
    on Jun 14, 2026
  6. 3 remaining items

  7. self-assigned this
    on Jul 6, 2026
  8. steipete commented on Jul 6, 2026

    @steipete
    Contributor

    Current main still declares channels.slack as a channel-restart prefix, and the Gateway rebuilds the Slack provider when any channels.slack.* path changes. A contributor exercised 14 direct token edits on current main; every non-coalesced edit produced the expected restart. That leaves the reported Control UI/container write path as the unproven boundary, not Bolt's per-App authorization cache.

    Please add one current-main or newest-release container reproduction with:

    • whether the token was saved through Control UI, config.patch, or direct file replacement;
    • the config-watcher health/status immediately before and after the save;
    • Gateway logs from the save through five seconds afterward, including whether restarting slack channel appears;
    • whether an unrelated config edit is detected in the same running container;
    • filesystem/mount type for the config path and whether the write replaces the inode.

    If the watcher reports healthy but misses the write, we can harden the watcher. If the Control UI/config RPC persists successfully without scheduling reload, we can fix that control-plane path. The existing evidence does not yet choose between them.

  9. added
    issue-rating: 🦐 gold shrimpDecent issue quality, but reproduction details are still incomplete.
    clawsweeper:needs-infoClawSweeper needs more reporter information before it can verify this issue.
    issue-rating: 🦪 silver shellfishThin issue quality; more reproduction proof or environment detail is needed.
    and removed
    clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.
    issue-rating: 🦪 silver shellfishThin issue quality; more reproduction proof or environment detail is needed.
    clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.
    clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.
    clawsweeper:needs-infoClawSweeper needs more reporter information before it can verify this issue.
    issue-rating: 🦐 gold shrimpDecent issue quality, but reproduction details are still incomplete.
    on Jul 31, 2026
  10. self-assigned this
    on Aug 12, 2026
  11. vincentkoc commented on Aug 12, 2026

    @vincentkoc
    Member

    Closing this as stale / not planned on the evidence currently available.

    Current main does not rely solely on the container filesystem watcher for Control UI writes: channel Save uses config.set, targeted config edits use config.patch, and both go through the canonical config writer, which emits an in-process config-write notification. Any channels.slack.* change plans a Slack channel restart. That restart stops and starts the channel, resolving the latest token and constructing a fresh Bolt App and receiver. Bolt's per-App authorization closure captures the token, so replacing the App is the correct cache boundary.

    The adjacent watcher/reload failure classes have also been repaired:

    All three fixes are contained in v2026.7.2-beta.7. The June watcher fallback from #92852 is also in stable v2026.7.1-2; the July recovery/coalescing fixes from #111049 and #110397 are not. This is therefore not an already-fixed closure for the reported stable/container case.

    The only concrete reproduction remains OpenClaw 2026.5.6 in the managed sandpaw-go-yard container. No current container reproduction or the evidence requested on July 6 was added: exact save path (config.set / config.patch / direct replacement), watcher health before and after the save, logs through five seconds after it, an unrelated-edit control, mount/filesystem type, and whether the save replaces the inode. Without that boundary evidence, there is no specific current defect we can safely repair.

    Please open a fresh report if this reproduces on a current release, with those exact details. That would let us distinguish a control-plane write notification failure from a bind-mount/inode watcher failure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

P2Normal backlog priority with limited blast radius.impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.issue-rating: 🦪 silver shellfishThin issue quality; more reproduction proof or environment detail is needed.staleMarked as stale due to inactivity

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions