Skip to content

fix: keep healthy channel accounts running when one credential fails - #109766

Merged
steipete merged 4 commits into
mainfrom
fix/channel-account-secretref-isolation
Jul 17, 2026
Merged

steipete merged 4 commits into
mainfrom
fix/channel-account-secretref-isolation

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Related: #101265

What Problem This Solves

Fixes an issue where operators using channel-account SecretRefs could lose Gateway channel activation when one account referenced a missing credential. A broken account could prevent healthy sibling accounts and unrelated channels from starting.

Why This Change Was Made

Channel collectors now assign every credential to its normalized account owner, including inherited top-level credentials used by multiple accounts. Gateway activation marks only the unavailable owner cold before resolving that account, while preserving strict failure for unknown ownership and each channel's existing mode-specific webhook ownership.

The change is limited to channel credential collection and channel activation. It adds no config, environment variable, UI, or capability surface.

User Impact

A missing credential for one channel account no longer takes down the Gateway or healthy sibling channel accounts. Status and doctor retain the typed degraded-owner evidence needed to diagnose the cold account.

Evidence

  • Focused local proof after the final rebase: 8 test files, 110 tests passed across 6 repository Vitest shards.
  • Fresh branch autoreview after the final rebase: clean, no actionable findings.
  • Exact changed-surface Testbox gate: GitHub Actions run 29561353107, including formatting, SDK surface/baseline, boundaries, all tsgo lanes, core and plugin lint, DB-first, cycles, and guards.
  • Real built-Gateway Testbox proof: a Discord account with a missing SecretRef stayed cold with SecretSurfaceUnavailableError; a healthy Discord sibling and Telegram started independently; doctor reported account:discord:broken (channels.discord.accounts.broken.token); the secret reference identifier was absent from status output. The fixture credentials then failed external authentication as expected, after activation had been demonstrated.

AI-assisted: implementation and review used Codex; maintainer-directed tests, hosted gates, and live Gateway proof verified the result.

@steipete
steipete requested a review from a team as a code owner July 17, 2026 07:27
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: discord Channel integration: discord channel: googlechat Channel integration: googlechat channel: matrix Channel integration: matrix channel: msteams Channel integration: msteams channel: slack Channel integration: slack gateway Gateway runtime commands Command implementations channel: feishu Channel integration: feishu channel: irc size: L maintainer Maintainer-authored PR labels Jul 17, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0900bd8445

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +240 to +241
owner: createChannelAccountSecretOwner(params.channelKey, accountId),
apply: params.apply,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep failed owners from reverting shared credentials

When a top-level credential is inherited by multiple accounts, this loop creates multiple owner-specific assignments that all call the same root-field apply. If one of those owners also has a different missing SecretRef, resolveAndApplySecretAssignments isolates that owner by applying every assignment's original ref back into config; that rewrites the shared top-level credential back to a SecretRef after another owner may have resolved it. In a Discord/Slack config where a healthy account inherits channels.<id>.token and a sibling has a missing account-specific secret, the healthy account can start with the unresolved object instead of the resolved token, defeating the isolation this change is meant to provide.

Useful? React with 👍 / 👎.

Comment on lines +71 to +74
active:
defaultAccountEnabled &&
!defaultAccountAccessTokenConfigured &&
!defaultScopedAccessTokenConfigured,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Resolve single-account Matrix accessToken refs

For the common config with no channels.matrix.accounts block, resolveChannelAccountSurface represents the default account with account pointing at the top-level Matrix object, so defaultAccountAccessTokenConfigured is true whenever this same channels.matrix.accessToken is a SecretRef. The new active condition then treats the top-level ref as shadowed and skips shared-runtime resolution/degraded-owner creation, so a missing top-level Matrix token won't isolate matrix:default and will instead fail later in the Matrix startup path.

Useful? React with 👍 / 👎.

@steipete
steipete force-pushed the fix/channel-account-secretref-isolation branch from 0900bd8 to e22bf86 Compare July 17, 2026 07:39

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e22bf863a6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +213 to +216
const owners = params.surface.hasExplicitAccounts
? params.surface.accounts.filter(params.inheritedAccountActive)
: params.activeWithoutAccounts
? [{ accountId: "default", account: {}, enabled: true }]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep disabled channels from resolving top-level refs

When a channel has explicit accounts but enabled: false, this branch no longer applies the old surface.channelEnabled guard before using topLevelInheritedAccountActive. Several existing predicates (for example SMS/QQ Bot/ClickClack implicit-default branches) can return true without checking enabled, so a disabled channel with a stale top-level SecretRef can now attempt resolution and fail startup instead of being reported as inactive.

Useful? React with 👍 / 👎.

!(
baseAccessTokenConfigured ||
envAccessTokenConfigured ||
defaultScopedAccessTokenConfigured ||
defaultAccountAccessTokenConfigured
defaultAccountAccessTokenConfigured ||
defaultAccountPasswordConfigured ||

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Resolve accountless Matrix password refs

For the common single-account Matrix config with no channels.matrix.accounts, defaultAccount is the synthetic account backed by the channel root, so defaultAccountPasswordConfigured is true whenever this same top-level channels.matrix.password SecretRef exists. That makes the assignment inactive, leaving the ref unresolved and preventing a missing password secret from degrading matrix:default as intended.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ca45dbb948

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@@ -550,6 +551,9 @@ export function createChannelManager(opts: ChannelManagerOptions): ChannelManage
};

try {
// Reject the account before plugin resolution so an explicit failed SecretRef cannot
// drift into a channel-specific environment or file fallback.
assertSecretOwnerAvailable("account", `${channelId}:${normalizeAccountId(id)}`);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Guard degraded accounts in status snapshots

This only rejects degraded owners on the startup path, but owner isolation leaves the unresolved SecretRef in the active config. getRuntimeSnapshot() still calls plugin.config.resolveAccount(cfg, id) for every listed account before consulting the stored runtime error; for isolated Google Chat/SMS/ClickClack accounts, those resolvers throw on unresolved SecretRefs, so readiness/status calls can throw after startup instead of reporting just that account cold. Apply the same degraded-owner guard in the snapshot path before resolving/describing accounts.

Useful? React with 👍 / 👎.

Comment on lines +213 to +214
const owners = params.surface.hasExplicitAccounts
? params.surface.accounts.filter(params.inheritedAccountActive)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep implicit-default refs on the default owner

In explicit-account configs this now treats topLevelInheritedAccountActive as an owner selector, but several existing callers pass channel-level implicit-default checks rather than per-account inheritance checks. For example SMS returns topLevelSmsAccountActive for every account and QQ Bot does the same for non-default accounts, so a top-level default SecretRef can be collected under unrelated named account owners; if that root ref is missing, those named accounts are marked unavailable even when they have their own credentials and do not inherit the default credential.

Useful? React with 👍 / 👎.

@steipete
steipete force-pushed the fix/channel-account-secretref-isolation branch from ca45dbb to 6235ddf Compare July 17, 2026 08:02
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Jul 17, 2026
@clawsweeper

clawsweeper Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed July 17, 2026, 4:06 AM ET / 08:06 UTC.

Summary
The PR partitions channel SecretRef failures by normalized account owner so unavailable account credentials do not prevent healthy sibling accounts or unrelated channels from activating.

PR surface: Source +103, Tests +342, Generated 0. Total +445 across 20 files.

Reproducibility: yes. at source level: configure a missing SecretRef on one account and a valid credential on a sibling, then start the Gateway and query readiness/status. The PR provides strong after-fix live proof for the startup path, though not a captured current-main failure transcript.

Review metrics: 1 noteworthy metric.

  • Plugin SDK contract: 1 generated API baseline changed. The shared channel-secret helper contract and behavior affect existing plugin collectors, so compatibility needs explicit sibling-surface coverage.

Stored data model
Persistent data-model change detected: migration/backfill/repair: src/commands/doctor-gateway-health.test.ts, persistent cache schema: src/plugin-sdk/channel-secret-basic-runtime.test.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: canonical
Canonical: #109766
Summary: This PR is the canonical channel-account follow-up to the previously merged generic SecretRef owner-isolation foundation.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🦐 gold shrimp
Proof: 🦞 diamond lobster
Patch quality: 🦐 gold shrimp
Result: needs maintainer review before merge.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Guard degraded owners before snapshot and status account resolution.
  • [P2] Correct implicit-default ownership and add regressions for affected sibling channel collectors.

Risk before merge

  • [P1] Runtime readiness or status snapshots can still throw after startup when an isolated account resolver receives the unresolved SecretRef.
  • [P1] Implicit-default top-level credentials can be attributed to unrelated named account owners, causing healthy accounts with independent credentials to be marked unavailable.
  • [P1] The shared plugin-SDK collector semantics change across existing channel plugins, so upgrade compatibility is not established until sibling collectors and snapshot paths are covered.

Maintainer options:

  1. Complete account isolation before merge (recommended)
    Guard all account-resolution paths and correct implicit-default owner selection, with regressions proving healthy named accounts and status endpoints remain operational.
  2. Pause the broad helper change
    Keep the PR open while narrowing the implementation if the shared plugin-SDK collector cannot safely preserve existing channel ownership semantics.

Next step before merge

  • [P2] Repair should stay on this maintainer-labeled PR branch for contributor and owner review rather than spawning an automated replacement work item.

Security
Cleared: The diff adds no dependency, workflow, permission, persistence, or secret-output surface, and its startup guard strengthens the explicit-SecretRef no-fallback boundary.

Review findings

  • [P2] Guard degraded accounts before building runtime snapshots — src/gateway/server-channels.ts:554
  • [P1] Keep implicit-default credentials scoped to the default owner — src/secrets/channel-secret-basic-runtime.ts:210-213
Review details

Best possible solution:

Apply degraded-owner checks consistently before every account resolver, preserve default-only ownership for implicit credentials, and add focused regressions for snapshot/status plus affected sibling channel collectors before merge.

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

Yes, at source level: configure a missing SecretRef on one account and a valid credential on a sibling, then start the Gateway and query readiness/status. The PR provides strong after-fix live proof for the startup path, though not a captured current-main failure transcript.

Is this the best way to solve the issue?

No, not yet; account isolation is the correct owner boundary, but the implementation must cover every account resolver and distinguish inherited credentials from implicit-default-only credentials.

Full review comments:

  • [P2] Guard degraded accounts before building runtime snapshots — src/gateway/server-channels.ts:554
    The new availability assertion only protects startAccount. Runtime snapshot and status code still resolves every listed account first, so isolated Google Chat, SMS, or ClickClack accounts can throw on the retained SecretRef and break readiness/status after an otherwise successful startup. Apply the same owner guard before resolving accounts in the snapshot path.
    Confidence: 0.98
  • [P1] Keep implicit-default credentials scoped to the default owner — src/secrets/channel-secret-basic-runtime.ts:210-213
    The shared collector now treats topLevelInheritedAccountActive as an owner selector, but existing implicit-default callers can return true for unrelated named accounts. A missing root credential can therefore cool accounts that use their own credentials; preserve a distinct default-only path or update every affected caller and add sibling regressions.
    Confidence: 0.95

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 6ac15970a742.

Label changes

Label changes:

  • add P1: The target bug can disable healthy channel workflows, while the remaining patch defects can still suppress accounts or break readiness and status operations.
  • add merge-risk: 🚨 compatibility: The shared exported channel-secret helper changes how existing plugin collectors assign top-level credentials to account owners.
  • add merge-risk: 🚨 message-delivery: Incorrect owner assignment can cool healthy named accounts and prevent their channel messages from being received or delivered.
  • add merge-risk: 🚨 availability: An isolated unresolved SecretRef can still make readiness or status snapshot resolution throw after Gateway startup.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides detailed after-fix built-Gateway live output demonstrating isolated Discord failure, healthy sibling and unrelated-channel activation, doctor diagnostics, and redaction; focused tests and hosted gates supplement that proof.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (live_output): The PR body provides detailed after-fix built-Gateway live output demonstrating isolated Discord failure, healthy sibling and unrelated-channel activation, doctor diagnostics, and redaction; focused tests and hosted gates supplement that proof.

Label justifications:

  • P1: The target bug can disable healthy channel workflows, while the remaining patch defects can still suppress accounts or break readiness and status operations.
  • merge-risk: 🚨 compatibility: The shared exported channel-secret helper changes how existing plugin collectors assign top-level credentials to account owners.
  • merge-risk: 🚨 message-delivery: Incorrect owner assignment can cool healthy named accounts and prevent their channel messages from being received or delivered.
  • merge-risk: 🚨 availability: An isolated unresolved SecretRef can still make readiness or status snapshot resolution throw after Gateway startup.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (live_output): The PR body provides detailed after-fix built-Gateway live output demonstrating isolated Discord failure, healthy sibling and unrelated-channel activation, doctor diagnostics, and redaction; focused tests and hosted gates supplement that proof.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides detailed after-fix built-Gateway live output demonstrating isolated Discord failure, healthy sibling and unrelated-channel activation, doctor diagnostics, and redaction; focused tests and hosted gates supplement that proof.
Evidence reviewed

PR surface:

Source +103, Tests +342, Generated 0. Total +445 across 20 files.

View PR surface stats
Area Files Added Removed Net
Source 10 197 94 +103
Tests 9 356 14 +342
Docs 0 0 0 0
Config 0 0 0 0
Generated 1 2 2 0
Other 0 0 0 0
Total 20 555 110 +445

What I checked:

  • Startup-only degraded-owner guard: The current head checks account availability immediately before the startup resolver, but the same account resolver is also used by runtime snapshot and status paths without this guard. (src/gateway/server-channels.ts:554, 6235ddf3b4c9)
  • Shared collector changes ownership semantics: The new shared collector uses the inherited-account predicate to select owners for a top-level credential; unchanged implicit-default channel callers can therefore associate a default-only credential with unrelated named accounts. (src/secrets/channel-secret-basic-runtime.ts:210, 6235ddf3b4c9)
  • Existing review findings remain applicable: The latest review comments identified the missing snapshot guard and implicit-default owner drift; the final changed-file set adds no snapshot guard and no corresponding repairs in the affected SMS or QQ Bot collectors. (src/gateway/server-channels.ts:554, 6235ddf3b4c9)
  • Real Gateway behavior proof: The PR body reports a built-Gateway run where a missing Discord account stayed cold, a healthy Discord sibling and Telegram started, doctor exposed the degraded owner, and SecretRef identifiers remained redacted. (6235ddf3b4c9)
  • Secret-owner isolation foundation: Merged pull request fix(secrets): keep startup alive when TTS SecretRefs are missing #101265 introduced typed provider and capability owner isolation and explicitly left channel-account partitioning as follow-up work. (src/secrets/runtime-degraded-state.ts, 17c2ce05d80a)

Likely related people:

  • snowzlmbot: Authored the merged generic SecretRef owner-isolation foundation that this channel-account work extends, including degraded-owner state, status, doctor, and strict fallback boundaries. (role: introduced behavior; confidence: high; commits: 287ab97c75fb, 17c2ce05d80a; files: src/secrets/runtime-degraded-state.ts, src/secrets/runtime.ts, src/commands/status.summary.test.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit 4ecd85e into main Jul 17, 2026
176 of 179 checks passed
@steipete
steipete deleted the fix/channel-account-secretref-isolation branch July 17, 2026 08:12
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 18, 2026
…penclaw#109766)

* fix(secrets): isolate channel account credentials

* fix(secrets): normalize Feishu default ownership

* fix(feishu): preserve accountless secret ownership

* fix(matrix): keep accountless top-level refs active
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
…penclaw#109766)

* fix(secrets): isolate channel account credentials

* fix(secrets): normalize Feishu default ownership

* fix(feishu): preserve accountless secret ownership

* fix(matrix): keep accountless top-level refs active
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord channel: feishu Channel integration: feishu channel: googlechat Channel integration: googlechat channel: irc channel: matrix Channel integration: matrix channel: msteams Channel integration: msteams channel: slack Channel integration: slack commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant