fix(mattermost): keep status read-only for SecretRef tokens#71024
fix(mattermost): keep status read-only for SecretRef tokens#71024afurm wants to merge 2 commits intoopenclaw:mainfrom
Conversation
c85286c to
cdf63f7
Compare
Greptile SummaryThis PR adds a read-only Confidence Score: 5/5Safe to merge; the fix is well-scoped, runtime token resolution is unchanged, and tests cover the primary scenario. Only one P2 edge-case finding remains: the botTokenSource/botTokenStatus priority when a configured_unavailable SecretRef coexists with an env token. This scenario (both sources simultaneously present) is uncommon in practice, and the primary crash fix is correct and well-tested. extensions/mattermost/src/mattermost/accounts.ts — the env-token vs SecretRef priority order in inspectMattermostAccount's source/status derivation. Prompt To Fix All With AIThis is a comment left during a code review.
Path: extensions/mattermost/src/mattermost/accounts.ts
Line: 185-198
Comment:
When a config-level SecretRef is `configured_unavailable` **and** an env token is also present, `botTokenSource` is forced to `"config"` and `botTokenStatus` is forced to `"configured_unavailable"` even though `botToken` is actually set to the live `envToken`. This means `probeAccount` (which reads `account.botToken`) would probe with the env token while the snapshot reports the account as credential-unavailable — a misleading inconsistency. The env-fallback branch should be evaluated before the SecretRef status takes precedence in both the source and status chains.
```suggestion
const botTokenSource: MattermostTokenSource = tokenInspection.botToken
? "config"
: envToken
? "env"
: tokenInspection.botTokenStatus === "configured_unavailable"
? "config"
: "none";
const botTokenStatus: MattermostCredentialStatus = tokenInspection.botToken
? "available"
: envToken
? "available"
: tokenInspection.botTokenStatus === "configured_unavailable"
? "configured_unavailable"
: "missing";
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "fix(mattermost): keep status read-only f..." | Re-trigger Greptile |
cdf63f7 to
40bbc37
Compare
40bbc37 to
88e624c
Compare
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
|
Codex review: needs changes before merge. Summary Reproducibility: yes. The original crash is reproduced by a Mattermost config with baseUrl plus an unresolved exec/keychain botToken SecretRef on current main, and the PR-specific regression is reproduced by adding MATTERMOST_BOT_TOKEN to that same config. Next step before merge Security Review findings
Review detailsBest possible solution: Land the Mattermost-owned read-only inspector/status snapshot fix after aligning credential precedence with strict runtime resolution, adding a SecretRef-plus-env regression test, and adding the active-version changelog entry. Do we have a high-confidence way to reproduce the issue? Yes. The original crash is reproduced by a Mattermost config with baseUrl plus an unresolved exec/keychain botToken SecretRef on current main, and the PR-specific regression is reproduced by adding MATTERMOST_BOT_TOKEN to that same config. Is this the best way to solve the issue? No. The chosen read-only inspector design is the narrow maintainable fix, but this implementation should preserve configured_unavailable ahead of env fallback unless runtime resolution semantics are changed too. Full review comments:
Overall correctness: patch is incorrect Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against f523620abe7f. |
Summary
openclaw statustext mode crashed when MattermostbotTokenused an unresolvedexec:keychainSecretRef.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause (if applicable)
inspectAccountpath. Status rendering fell back toresolveAccount, which throws on unresolved SecretRefs.Regression Test Plan (if applicable)
extensions/mattermost/src/mattermost/accounts.test.tsextensions/mattermost/src/channel-actions-setup-status.contract.test.tsUser-visible / Behavior Changes
openclaw statusno longer crashes for Mattermost accounts whose bot token is configured as an unresolved SecretRef. It reports degraded credential availability instead.Diagram (if applicable)
Security Impact (required)
No)Yes)No)No)No)Yes, explain risk + mitigation: Read-only status now detects configured SecretRefs without resolving them. It does not expose token values, and runtime resolution remains strict.Repro + Verification
Environment
channels.mattermost.botTokenasexec:keychainSecretRef plusbaseUrlSteps
botTokenas an unresolved SecretRef.openclaw status.Expected
Actual
Evidence
Validation:
pnpm test extensions/mattermost/src/mattermost/accounts.test.ts extensions/mattermost/src/channel-actions-setup-status.contract.test.tspnpm check:changedHuman Verification (required)
botTokenStatus: configured_unavailable.resolveMattermostAccountstill throws on unresolved SecretRefs.exec:keychainsecret provider returning a token.Review Conversations
Compatibility / Migration
Yes)No)No)Risks and Mitigations