Skip to content

fix: sandbox explain reports channel=(unknown) and allowedByConfig=false for telegram slash sessions - #189343

Merged
obviyus merged 4 commits into
openclaw:mainfrom
nikolas-sapa:fix/telegram-slash-session-channel
Nov 14, 2026
Merged

obviyus merged 4 commits into
openclaw:mainfrom
nikolas-sapa:fix/telegram-slash-session-channel

Conversation

@nikolas-sapa

@nikolas-sapa nikolas-sapa commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Related: #51245 (both halves covered: this fixes the sandbox explain diagnostic, and adds regression tests proving the live elevated gate already authorizes Telegram slash senders on main — no runtime change needed there. A real-bot live check would still need a maintainer with a Telegram account, so the issue can stay open until then.)

What Problem This Solves

openclaw sandbox explain --session telegram:slash:<id> reports channel: (unknown) and allowedByConfig: false when the CLI's plugin registry has no channel plugins (the sandbox-backends scope is empty for stock docker/podman configs), even with tools.elevated.allowFrom.telegram configured.

User Impact

openclaw sandbox explain shows the right channel and allowedByConfig: true for telegram sessions on stock docker/podman setups, so elevated-tool allow lists can be checked without confusing (unknown) output.

Why This Change Was Made

  • Fall back to the static bundled channel catalog after the runtime registry misses, for both the stored-delivery and the parsed-key paths.
  • Stored-delivery regression test uses a session key with no channel (agent:builder:main), so only the stored delivery context supplies telegram. Fails if the stored-delivery fallback is removed.

Evidence

Real CLI proof at exact head 948c62ef4291 (this branch merged with current main; maintainer run). openclaw sandbox explain --session telegram:slash:123456, run from source in an isolated HOME whose only config is {"tools":{"elevated":{"enabled":true,"allowFrom":{"telegram":["123456"]}}}}:

run Elevated block --json elevated
main 520f18975936 channel: (unknown), allowedByConfig: false no channel, allowedByConfig: false, allowFrom: {}
head 948c62ef4291 channel: telegram, allowedByConfig: true channel: "telegram", allowedByConfig: true, allowFrom.global: ["123456"]
  • Regression: with src/commands/sandbox-explain.ts reset to main, both new sandbox-explain.test.ts cases fail (2 failed, 18 passed); on the head 20/20 pass, and reply-elevated.test.ts 10/10. oxlint/oxfmt clean on the touched files.
  • This is CLI diagnostics only; Telegram message handling is unchanged, so no Telegram E2E applies.

Contributor evidence

Setup: Linux, built CLI, isolated HOME.

Config: {"tools":{"elevated":{"enabled":true,"allowFrom":{"telegram":["123456"]}}}}

Before (main; sandbox-explain.ts and channels/registry.ts):

Elevated:
  enabled: true
  channel: (unknown)
  allowedByConfig: false

After (this branch):

Elevated:
  enabled: true
  channel: telegram
  allowedByConfig: true

--json before/after: before "allowedByConfig": false (no channel field); after "channel": "telegram", "allowedByConfig": true

Tests

  • Red (fix reverted): Tests 2 failed | 18 skipped (20) (exit 1), both tests fail
  • Red (stored-delivery fallback only reverted): Tests 1 failed | 1 passed | 18 skipped (20) (exit 1), the stored-delivery test fails
  • Green (branch): Tests 2 passed | 18 skipped (20) (exit 0); whole file: Tests 20 passed (20) (exit 0)
  • oxlint exit 0, format check exit 0, check:test-mock-exports exit 0, git diff --check exit 0

Live elevated gate (second half of #51245)

Commit ea18bc782 (cherry-picked from @jerome-queck's #189880, authorship kept) adds regression tests for the runtime gate (resolveElevatedPermissions, used by get-reply-directives for live Telegram turns). On current main, Telegram native slash turns reach the gate with Provider: "telegram", and tools.elevated.allowFrom.telegram is looked up by that provider. With no channel plugin registered, a Telegram slash context (SessionKey: telegram:slash:123456, SenderId: 123456) is authorized for ["123456"], [123456] and ["telegram:123456"], and a different sender is still denied. So no runtime code change is needed on main — the live elevated path already passes per these tests (which include #182406). The tests keep it that way; the sandbox explain fix above was the remaining part of the issue.

$ node scripts/run-vitest.mjs run src/auto-reply/reply/reply-elevated.test.ts src/commands/sandbox-explain.test.ts
 ✓ telegram slash session authorizes a numeric sender id
 ✓ telegram slash session authorizes a number-typed sender id
 ✓ telegram slash session authorizes a telegram:-prefixed sender id
 ✓ telegram slash session denies a different sender
 Test Files  2 passed (2)
      Tests  30 passed (30)

Thanks to @jerome-queck for the stored-delivery test isolation case and the live elevated-gate regression tests.

…gins

The sandbox explain CLI activates a sandbox-backends-scoped plugin registry,
which is empty for stock docker/podman configs, so normalizeAnyChannelId
could never resolve bundled channels like telegram and elevated diagnostics
kept reporting channel=(unknown) with allowedByConfig=false for
telegram:slash:* sessions (issue openclaw#51245). Fall back to the static bundled
channel catalog after the runtime registry lookup misses, covering both the
stored-delivery and parsed-key channel paths.

Red/green: two new tests in src/commands/sandbox-explain.test.ts set an
empty plugin registry exactly like the real CLI and fail on main (channel
undefined), pass with the fallback (20/20).
@clawsweeper

clawsweeper Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations docker Docker and sandbox tooling size: S labels Oct 31, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. 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 clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 31, 2026
@clawsweeper

clawsweeper Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR lets sandbox explain resolve bundled channels when its scoped plugin registry contains no channel plugins.

Example: Run openclaw sandbox explain --session telegram:slash:123456 with tools.elevated.allowFrom.telegram set to ["123456"].

  • Before: The report shows channel: (unknown) and allowedByConfig: false.
  • After: The report shows channel: telegram and allowedByConfig: true.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The diagnostic patch is focused and proven through the CLI; overall scope remains partial against the linked issue's live-execution report.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): Supplied isolated Linux CLI output exercises sandbox explain with an empty channel registry and Telegram allowlist, demonstrating corrected human-readable and JSON results at the reviewed head.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Partial
User problem: Operators see an unknown channel and a false elevated-configuration result despite configuring a Telegram allowlist.
Reason: The diagnostic repair has clear value and preserves the documented authorization boundary; the linked issue's separate live-denial report remains unresolved.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR fixes a current diagnostic bug with a small, supported change and credible CLI proof; no actionable code defects were found.

Priority: P2
Reviewed head: 948c62ef429185b2725ea34fd19ce2c7bb724638

Before merge

None.

Findings

None.

Agent review details

How this fits together

The sandbox CLI reads configuration and session metadata, identifies the applicable channel, and renders sandbox and elevated-policy diagnostics without authorizing execution.

flowchart TD
  A[Sandbox explain CLI] --> B[Configuration and session metadata]
  B --> C[Stored channel or session key]
  C --> D[Registered channel lookup]
  D --> E[Bundled catalog fallback]
  E --> F[Elevated configuration report]
Loading

Technical review

Best possible solution:

Retain the existing registry-first lookup with bundled-catalog fallback in the diagnostic command and keep live authorization investigation in the linked issue.

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

Current-main source exposes the empty-registry failure, and the supplied real CLI before/after output corroborates it; no target code was executed during this review.

Is this the best way to solve the issue?

The patch is the smallest complete diagnostic repair: it reuses existing channel owners, preserves registered-plugin precedence, and covers the two distinct lookup paths.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 3588c0514ac8.

Provenance checked

  • Registry-based diagnostic channel resolution keeps the original intent (6a3ed5c: The slash/control-command security change switched the inspector from plugin-index normalization to the registry facade; this PR preserves that lookup and adds metadata fallback only for diagnostics.)
  • Stored-delivery precedence and session-key fallback keeps the original intent (refactor: localize single-consumer preparation and output #180547: The refactor localized single-consumer preparation while preserving stored-session channel selection; both paths and their precedence remain intact.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 1fb7766 adds src/commands/sandbox-explain.ts:169 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 1fb7766685a5; files: src/commands/sandbox-explain.ts)

PR surface

Source +6, Tests +101. Total +107 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 9 3 +6
Tests 2 101 0 +101
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 110 3 +107

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Incorrect elevated-policy diagnostics mislead operators, but this PR does not establish a current execution failure or authorization bypass.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (3 earlier review cycles)
  • reviewed 2026-10-31T12:21:05.840Z sha 4e58d9b :: needs real behavior proof before merge. :: none
  • reviewed 2026-11-01T07:41:38.743Z sha 09f70de :: needs maintainer review before merge. :: none
  • reviewed 2026-11-13T05:57:43.747Z sha ea18bc7 :: needs maintainer review before merge. :: none

Reviewed November 14, 2026, 1:54 AM ET / 06:54 UTC (Revision 4).

@jerome-queck

Copy link
Copy Markdown
Contributor

Hi @nikolas-sapa, thanks for this fix. I opened #189880, which cherry-picks your commit unchanged (authorship kept) and adds two things ClawSweeper asked for here: built-CLI before/after output on Linux, and a stored-delivery test that uses a channel-less session key, so it fails if the stored-delivery fallback is removed. Credit for the fix is yours. If you'd rather fold the test change into this PR, I'm happy to close mine.

@nikolas-sapa

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@jerome-queck Folded in the channel-less session key test isolation case and updated the description with the Linux CLI before/after proof. Thanks for the test case!

@clawsweeper

clawsweeper Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed 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. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 1, 2026
@jerome-queck

jerome-queck commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Hi @nikolas-sapa, thanks for folding in the test and proof! ClawSweeper keeps overall at 3/6 because it rates the fix scope as Partial: #51245 also covers the live elevated-exec denial for Telegram slash sessions, and this PR only touches sandbox explain.

I looked at the live half. On current main the runtime gate (resolveElevatedPermissions, called from get-reply-directives) already authorizes a Telegram slash sender listed in tools.elevated.allowFrom.telegram, even with no channel plugin registered. So no runtime code change is needed, only tests that prove it. I added those in #189880 (commit 553345060b6, tests only, one file).

To fold it in:

git fetch https://github.com/jerome-queck/openclaw.git fix/sandbox-explain-bundled-channel-companion
git cherry-pick 553345060b6
npx vitest run src/auto-reply/reply/reply-elevated.test.ts src/commands/sandbox-explain.test.ts

Then add a short "Live elevated gate" note to your body's Evidence section. You can copy the one from #189880's description: the four telegram slash session … passing test lines, plus a line saying the live elevated path passes on main per those tests (it includes #182406). After that, comment @clawsweeper re-review.

I can't prove it against a real Telegram account from Linux, so if a maintainer wants that, it would need a real bot. Once you've folded it in, I'll close #189880 in favor of yours.

…gate

Covers the live half of openclaw#51245: a Telegram native slash context with no
channel plugin registered is authorized by tools.elevated.allowFrom.telegram
and a different sender is still denied.
@nikolas-sapa

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@jerome-queck Folded in your live elevated-gate tests (cherry-picked as ea18bc7, authorship kept — note it rebased to dff3669 on your branch, same diff). Verified locally: 30/30 pass across both files, test-lines ratchet OK with slack. Body updated with the Live elevated gate section.

@clawsweeper

clawsweeper Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 13, 2026
@obviyus

obviyus commented Nov 14, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 14, 2026
@obviyus
obviyus merged commit c232d50 into openclaw:main Nov 14, 2026
120 of 122 checks passed
@obviyus

obviyus commented Nov 14, 2026

Copy link
Copy Markdown
Collaborator

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 15, 2026
…lse for telegram slash sessions (openclaw#189343)

* fix(sandbox): resolve bundled channels in explain without channel plugins

The sandbox explain CLI activates a sandbox-backends-scoped plugin registry,
which is empty for stock docker/podman configs, so normalizeAnyChannelId
could never resolve bundled channels like telegram and elevated diagnostics
kept reporting channel=(unknown) with allowedByConfig=false for
telegram:slash:* sessions (issue openclaw#51245). Fall back to the static bundled
channel catalog after the runtime registry lookup misses, covering both the
stored-delivery and parsed-key channel paths.

Red/green: two new tests in src/commands/sandbox-explain.test.ts set an
empty plugin registry exactly like the real CLI and fail on main (channel
undefined), pass with the fallback (20/20).

* test(sandbox-explain): isolate stored delivery fallback test with channel-less key

* test(elevated): pin Telegram slash allowFrom in the runtime elevated gate

Covers the live half of openclaw#51245: a Telegram native slash context with no
channel plugin registered is authorized by tools.elevated.allowFrom.telegram
and a different sender is still denied.

---------

Co-authored-by: Jerome <[email protected]>
Co-authored-by: obviyus <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations docker Docker and sandbox tooling P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants