Repository navigation
fix: keep healthy channel accounts running when one credential fails - #109766
Conversation
There was a problem hiding this comment.
💡 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".
| owner: createChannelAccountSecretOwner(params.channelKey, accountId), | ||
| apply: params.apply, |
There was a problem hiding this comment.
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 👍 / 👎.
| active: | ||
| defaultAccountEnabled && | ||
| !defaultAccountAccessTokenConfigured && | ||
| !defaultScopedAccessTokenConfigured, |
There was a problem hiding this comment.
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 👍 / 👎.
0900bd8 to
e22bf86
Compare
There was a problem hiding this comment.
💡 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".
| const owners = params.surface.hasExplicitAccounts | ||
| ? params.surface.accounts.filter(params.inheritedAccountActive) | ||
| : params.activeWithoutAccounts | ||
| ? [{ accountId: "default", account: {}, enabled: true }] |
There was a problem hiding this comment.
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 || |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
💡 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)}`); | |||
There was a problem hiding this comment.
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 👍 / 👎.
| const owners = params.surface.hasExplicitAccounts | ||
| ? params.surface.accounts.filter(params.inheritedAccountActive) |
There was a problem hiding this comment.
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 👍 / 👎.
ca45dbb to
6235ddf
Compare
|
Codex review: found issues before merge. Reviewed July 17, 2026, 4:06 AM ET / 08:06 UTC. Summary 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.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest 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:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 6ac15970a742. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +103, Tests +342, Generated 0. Total +445 across 20 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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
|
|
Merged via squash.
|
…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
…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
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
SecretSurfaceUnavailableError; a healthy Discord sibling and Telegram started independently; doctor reportedaccount: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.