Skip to content

fix(mattermost): keep status read-only for SecretRef tokens - #71024

Closed
afurm wants to merge 2 commits into
openclaw:mainfrom
afurm:af/fix-mattermost-status-secretref
Closed

afurm wants to merge 2 commits into
openclaw:mainfrom
afurm:af/fix-mattermost-status-secretref

Conversation

@afurm

@afurm afurm commented Apr 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Problem: openclaw status text mode crashed when Mattermost botToken used an unresolved exec:keychain SecretRef.
  • Why it matters: Mattermost could be healthy at runtime, but read-only diagnostics failed before printing the channel table.
  • What changed: Added a Mattermost read-only account inspector that reports configured-but-unavailable credential metadata without dereferencing the secret, and taught status snapshots to preserve that state.
  • What did NOT change (scope boundary): Runtime Mattermost token resolution remains strict; this only changes read-only inspection/status behavior.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

Root Cause (if applicable)

  • Root cause: Mattermost had strict runtime account resolution but no read-only inspectAccount path. Status rendering fell back to resolveAccount, which throws on unresolved SecretRefs.
  • Missing detection / guardrail: No Mattermost regression test covered read-only status inspection with an unresolved SecretRef credential.
  • Contributing context (if known): Telegram, Discord, and Slack already had read-only inspectors; Mattermost was missing the equivalent path.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file:
    • extensions/mattermost/src/mattermost/accounts.test.ts
    • extensions/mattermost/src/channel-actions-setup-status.contract.test.ts
  • Scenario the test should lock in: unresolved Mattermost SecretRef bot tokens are reported as configured/unavailable in read-only inspection without throwing.
  • Why this is the smallest reliable guardrail: It tests the plugin resolver and the status snapshot contract directly without requiring a live Mattermost server.
  • Existing test that already covers this (if any): None.
  • If no new test is added, why not: N/A.

User-visible / Behavior Changes

openclaw status no longer crashes for Mattermost accounts whose bot token is configured as an unresolved SecretRef. It reports degraded credential availability instead.

Diagram (if applicable)

Before:
openclaw status -> Mattermost resolveAccount -> unresolved SecretRef throw -> CLI crash

After:
openclaw status -> Mattermost inspectAccount -> configured_unavailable metadata -> status table renders

Security Impact (required)

  • New permissions/capabilities? (No)
  • Secrets/tokens handling changed? (Yes)
  • New/changed network calls? (No)
  • Command/tool execution surface changed? (No)
  • Data access scope changed? (No)
  • If any 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

  • OS: macOS local checkout
  • Runtime/container: Node 22 / pnpm
  • Model/provider: N/A
  • Integration/channel (if any): Mattermost
  • Relevant config (redacted): channels.mattermost.botToken as exec:keychain SecretRef plus baseUrl

Steps

  1. Configure Mattermost with botToken as an unresolved SecretRef.
  2. Run openclaw status.
  3. Inspect the Mattermost status row.

Expected

  • Status renders and reports Mattermost as configured with unavailable credentials.

Actual

  • Fixed by this PR. Before the fix, status crashed with an unresolved SecretRef error.

Evidence

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Validation:

  • pnpm test extensions/mattermost/src/mattermost/accounts.test.ts extensions/mattermost/src/channel-actions-setup-status.contract.test.ts
  • pnpm check:changed

Human Verification (required)

  • Verified scenarios:
    • Mattermost account inspection preserves unresolved SecretRef state without dereferencing the secret.
    • Mattermost status snapshots include botTokenStatus: configured_unavailable.
    • Changed-lane validation passed.
  • Edge cases checked:
    • Runtime resolveMattermostAccount still throws on unresolved SecretRefs.
    • Read-only inspection treats SecretRef + baseUrl as configured but unavailable.
  • What you did not verify:
    • A live Mattermost server connection.
    • A real exec:keychain secret provider returning a token.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? (Yes)
  • Config/env changes? (No)
  • Migration needed? (No)
  • If yes, exact upgrade steps: N/A.

Risks and Mitigations

  • Risk: Status may treat a configured-but-unavailable SecretRef as configured even when the command cannot read it.
    • Mitigation: The row is marked with unavailable credential metadata, and runtime token use still requires successful strict resolution.

@openclaw-barnacle openclaw-barnacle Bot added channel: mattermost Channel integration: mattermost size: S labels Apr 24, 2026
@afurm
afurm force-pushed the af/fix-mattermost-status-secretref branch from c85286c to cdf63f7 Compare April 24, 2026 08:32
@greptile-apps

greptile-apps Bot commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a read-only inspectMattermostAccount path that detects configured-but-unresolved SecretRef bot tokens without dereferencing them, fixing a crash in openclaw status for Mattermost accounts whose botToken is an exec:keychain SecretRef. The new path is wired into mattermostConfigAdapter.inspectAccount and the status snapshot preserves the botTokenStatus: configured_unavailable field through resolveAccountSnapshot.

Confidence Score: 5/5

Safe 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 AI
This 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

@afurm
afurm force-pushed the af/fix-mattermost-status-secretref branch from cdf63f7 to 40bbc37 Compare April 24, 2026 08:34
@afurm
afurm force-pushed the af/fix-mattermost-status-secretref branch from 40bbc37 to 88e624c Compare April 24, 2026 08:36
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@clawsweeper

clawsweeper Bot commented Apr 29, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the contribution. This PR still needs the requested real-behavior proof, and the branch has been idle since that ask.

Close this stale external PR: its focused SecretRef-status idea is plausible, but the branch has been inactive since April 24, 2026, is currently dirty against main, and has not supplied the requested inspectable real-behavior proof after the May 20, 2026 proof request.

So I’m closing this for now to keep the review queue honest. Please reopen or open a fresh PR with real-behavior proof (a live run, logs, or a reproducible validation transcript) and it will be reviewed again.

Review details

Best possible solution:

Keep the current generic degraded-read-only SecretRef behavior; if a Mattermost-specific gap still reproduces, open a fresh, rebased narrow PR with a regression test and redacted terminal proof from openclaw status.

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

Yes, from source and the reported configuration: an unresolved Mattermost botToken reaches strict resolution unless the read-only path opts into the existing non-strict mode. No fresh runtime reproduction was supplied on the current head.

Is this the best way to solve the issue?

No for this branch as it stands: its April implementation is dirty against current main and lacks real behavior proof, while the current code and docs already establish a broader read-only SecretRef contract.

Security review:

Security review cleared: The proposed diff is limited to read-only credential inspection and status metadata; it adds no execution, network, dependency, permission, or secret-exposure path.

AGENTS.md: found and applied where relevant.

What I checked:

  • Current read-only resolution surface: Current Mattermost account resolution retains a read-only allowUnresolvedSecretRef mode that uses non-strict secret normalization, while strict resolution remains the default runtime path. (extensions/mattermost/src/mattermost/accounts.ts:731, 99046179a8fe)
  • Current status contract: Current channel documentation says SecretRef-backed credentials unavailable to a command should be reported as configured with degraded notes rather than aborting the command, so any revived patch must align with the current generic inspection/status contract. Public docs: docs/cli/channels.md. (docs/cli/channels.md:20, 99046179a8fe)
  • Proof window and inactivity: The PR head last changed on April 24, 2026; status: 📣 needs proof and triage: needs-real-behavior-proof were applied on May 20, 2026, and the visible follow-up activity is automated stale handling rather than contributor proof or maintainer engagement.
  • Current branch state: The GitHub context reports the current head as not cleanly mergeable (mergeableState: dirty), so the old branch cannot be landed without a rebase and fresh review.
  • Existing platform direction: The shipped release notes credit joshavant for aligning SecretRef inspect-versus-strict handling across plugin preload, read-only status/agents surfaces, and runtime auth paths, matching the broader behavior this PR was trying to address. (CHANGELOG.md, 041266a)

Likely related people:

  • joshavant: The v2026.4.15 release notes credit this contributor for the broader SecretRef inspect-versus-strict handling work spanning read-only status and runtime paths. (role: recent area contributor; confidence: medium; commits: 041266a; files: extensions/mattermost/src/mattermost/accounts.ts, docs/cli/channels.md)

Codex review notes: model internal, reasoning high; reviewed against 99046179a8fe.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. labels May 20, 2026
@clawsweeper

clawsweeper Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat.

Where did the egg go?
  • The egg game starts only after the PR passes the real-behavior proof check.
  • Before that, no creature or rarity is rolled. The treat waits for real proof.
  • This is still just collectible flavor: proof affects review readiness, not creature quality.

@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. label May 20, 2026
@openclaw-barnacle

Copy link
Copy Markdown

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

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Jun 7, 2026
@clawsweeper clawsweeper Bot added rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jun 7, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Jun 13, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Jun 13, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jun 15, 2026
@openclaw-barnacle

Copy link
Copy Markdown

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

@openclaw-barnacle openclaw-barnacle Bot added stale Marked as stale due to inactivity triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Jul 18, 2026
@clawsweeper

clawsweeper Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper applied the proposed close for this PR.

@clawsweeper clawsweeper Bot closed this Jul 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: mattermost Channel integration: mattermost merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S stale Marked as stale due to inactivity status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

openclaw status (text mode) fails on Mattermost exec:keychain SecretRef — other channels with same pattern work

1 participant