Skip to content

fix: allow unlocked Discord thread reopening - #150216

Merged
shakkernerd merged 4 commits into
mainfrom
fix/discord-reopen-permission
Sep 16, 2026
Merged

shakkernerd merged 4 commits into
mainfrom
fix/discord-reopen-permission

Conversation

@shakkernerd

@shakkernerd shakkernerd commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes the registered Discord channel-edit action incorrectly demanding Manage Threads when a sender with Send Messages reopens an unlocked archived thread. OpenClaw treated options omitted by the caller as additional channel edits, so the lower-permission exception never applied through the normal action adapter.

User Impact

Senders with current access and Send Messages on a thread's parent channel can explicitly reopen an unlocked archived thread instead of receiving an incorrect permissions error. Having only Send Messages in Threads does not authorize the explicit edit; Discord uses that separate permission when posting automatically reopens a thread. A private-thread nonmember or a sender whose View Channel access was removed remains blocked. Reopening a locked thread, unlocking it, or combining the reopen with another edit still requires Manage Threads. The change does not add a permission, action, setting, or migration.

Why This Change Was Made

The registered adapter normalizes the channel edit before invoking the guild runtime. The runtime's permission selector previously checked whether optional keys existed, so adapter normalization made a pure reopen indistinguishable from a reopen combined with other edits. It now classifies the existing normalized payload itself, including availableTags, keeping permission selection aligned with the payload sent to Discord while preserving stronger authorization for explicit changes.

The selector also now uses Send Messages, as required by Discord's Modify Channel contract for an unlocked-thread unarchive, rather than the independent thread-posting permission. OpenClaw resolves the current sender's View Channel access and private-thread membership after the permission check and before dispatch, so the exception cannot borrow parent permission bits for an inaccessible thread.

Evidence

A focused regression exercises the registered channel-edit adapter, real permission and access owners, and queued REST client through a secretless loopback. The authorized case reaches exactly one Discord PATCH containing only {"archived":false}. A private-thread nonmember and a sender with a parent overwrite removing View Channel are both rejected before any PATCH. The same test rejects Send Messages in Threads and verifies locked threads plus explicit unlock, flag, parent, and tag edits remain on the stronger path.

  • node scripts/run-vitest.mjs extensions/discord/src/actions/handle-action.guild-admin.test.ts extensions/discord/src/actions/runtime.test.ts — 2 files, 176 tests passed locally.
  • pnpm check:changed on Blacksmith Testbox — exact 2a116aa / 36551b1dadda source passed the 176 affected tests, extension production/test typechecks, and every selected gate in 5m09s.
  • Exact-head independent review found no P0–P2 defect. Hosted CI passed every selected job, including channel contracts, build artifacts, production/test types, lint, security, and baseline ratchets.

@clawsweeper

clawsweeper Bot commented Sep 16, 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 channel: discord Channel integration: discord size: S maintainer Maintainer-authored PR labels Sep 16, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. 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 Sep 16, 2026
@clawsweeper

clawsweeper Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 16, 2026, 3:15 PM ET / 19:15 UTC (Revision 3).

ClawSweeper review

What this changes

The Discord plugin allows authorized senders to reopen unlocked archived threads while retaining stronger permissions for locked threads and combined edits.

Merge readiness

✅ Ready for maintainer review

This remains a useful fix: current main still rejects legitimate thread reopens through the registered adapter. The prior sender-access finding is addressed, and no blocking defect remains in the reviewed patch.

Priority: P2
Reviewed head: 2a116aa91dfc1f7abb1aa735bd486d9f50e4acc0

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with meaningful allowed/forbidden boundary coverage and successful CI on the reviewed head.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The reported passing production-path loopback exercises the registered channel-edit adapter, real permission/access owners, and queued REST client: an authorized sender produces one reopen PATCH, while private nonmembership and revoked visibility produce none. This satisfies the relevant authority-boundary proof for this member-authored PR; it does not claim a live Discord-server run.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The reported passing production-path loopback exercises the registered channel-edit adapter, real permission/access owners, and queued REST client: an authorized sender produces one reopen PATCH, while private nonmembership and revoked visibility produce none. This satisfies the relevant authority-boundary proof for this member-authored PR; it does not claim a live Discord-server run.
Evidence reviewed 7 items Current main still contains the defect: At the fetched main revision, the permission selector checks whether optional keys exist and uses SendMessagesInThreads. The registered adapter supplies normalized optional keys, preventing the pure-reopen exception from applying.
Introduced repair and prior finding resolution: The complete host-pinned introduced patch derives the exception from normalized values and invokes the existing visibility/private-membership owner before dispatch. This addresses the prior review's sender-access finding without introducing another authorization owner.
Allowed and forbidden final-effect coverage: The supplied PR body reports successful execution of the registered adapter with real permission owners and the queued REST client against a secretless HTTP loopback. The inspected test asserts exactly one archived:false PATCH for an authorized sender and zero PATCH requests for private-thread nonmembers, revoked visibility, insufficient permission, locked threads, and combined edits.
Findings None None.
Security None None.

How this fits together

Discord channel actions translate agent requests into Discord API operations. The guild-action permission owner checks the requesting sender before the bot sends a channel update.

flowchart TD
  A[Channel edit request] --> B[Normalize edit payload]
  B --> C{Only reopen an unlocked thread?}
  C -->|Yes| D[Check send permission and thread access]
  C -->|No| E[Check management permission]
  D --> F{Authorized?}
  E --> F
  F -->|Yes| G[Discord channel update]
  F -->|No| H[Permission error]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +9, Tests +156. Total +165 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 1 21 12 +9
Tests 3 163 7 +156
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 184 19 +165

Review metrics

Metric Value Why it matters
Production versus test growth production +9 net lines; tests and test support +156 net lines The small production increase adds the missing access check, while most growth exercises authorization through the registered action and actual HTTP boundary.

Technical review

Best possible solution:

Keep the existing normalized-payload and permission owners aligned so accessible unlocked-thread reopens succeed without weakening authorization for other edits.

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

Yes, from source: the registered adapter materializes omitted optional fields, and current main treats their presence as additional edits. This review did not execute a current-main reproduction.

Is this the best way to solve the issue?

Yes. Reusing the normalized edit payload and existing thread-access owner repairs the actual adapter path while preserving stronger checks for combined or locked-thread edits.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The reported passing production-path loopback exercises the registered channel-edit adapter, real permission/access owners, and queued REST client: an authorized sender produces one reopen PATCH, while private nonmembership and revoked visibility produce none. This satisfies the relevant authority-boundary proof for this member-authored PR; it does not claim a live Discord-server run.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The reported passing production-path loopback exercises the registered channel-edit adapter, real permission/access owners, and queued REST client: an authorized sender produces one reopen PATCH, while private nonmembership and revoked visibility produce none. This satisfies the relevant authority-boundary proof for this member-authored PR; it does not claim a live Discord-server run.

Label justifications:

  • P2: This repairs a bounded Discord channel-management failure without evidence of a wider outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The reported passing production-path loopback exercises the registered channel-edit adapter, real permission/access owners, and queued REST client: an authorized sender produces one reopen PATCH, while private nonmembership and revoked visibility produce none. This satisfies the relevant authority-boundary proof for this member-authored PR; it does not claim a live Discord-server run.
  • proof: sufficient: Contributor real behavior proof is sufficient. The reported passing production-path loopback exercises the registered channel-edit adapter, real permission/access owners, and queued REST client: an authorized sender produces one reopen PATCH, while private nonmembership and revoked visibility produce none. This satisfies the relevant authority-boundary proof for this member-authored PR; it does not claim a live Discord-server run.

Evidence

What I checked:

  • Current main still contains the defect: At the fetched main revision, the permission selector checks whether optional keys exist and uses SendMessagesInThreads. The registered adapter supplies normalized optional keys, preventing the pure-reopen exception from applying. (extensions/discord/src/actions/runtime.guild.ts:185, e2eb18b701b4)
  • Introduced repair and prior finding resolution: The complete host-pinned introduced patch derives the exception from normalized values and invokes the existing visibility/private-membership owner before dispatch. This addresses the prior review's sender-access finding without introducing another authorization owner. (extensions/discord/src/actions/runtime.guild.ts:185, 2a116aa91dfc)
  • Allowed and forbidden final-effect coverage: The supplied PR body reports successful execution of the registered adapter with real permission owners and the queued REST client against a secretless HTTP loopback. The inspected test asserts exactly one archived:false PATCH for an authorized sender and zero PATCH requests for private-thread nonmembers, revoked visibility, insufficient permission, locked threads, and combined edits. (extensions/discord/src/actions/handle-action.guild-admin.test.ts:116, 2a116aa91dfc)
  • Authoritative Discord permission contract: The PR explicitly depends on Discord's Modify Channel contract. The inspected official documentation specifies Send Messages for unarchiving an unlocked thread and Manage Threads otherwise: https://docs.discord.com/developers/resources/channel#modify-channel.
  • CI identity and result: GitHub confirms the linked workflow completed successfully on the exact reviewed head. The supplied body separately reports 176 affected tests and selected production/test typechecks passing. No target code or tests were executed during this read-only review. (2a116aa91dfc)
  • Current-main routing history: File history identifies recent permission work by Alix-007 and repeated Discord authorization/classification work by Peter Steinberger. Exact line-introduction attribution remains unverified because some historical blobs were unavailable. (extensions/discord/src/send.permissions.ts, e2eb18b701b4)

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Alix-007: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • 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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-16T18:22:21.900Z sha 13eb969 :: needs real behavior proof before merge. :: [P1] Require sender access before allowing low-permission thread reopens
  • reviewed 2026-09-16T18:39:04.793Z sha 5db04fa :: needs real behavior proof before merge. :: [P1] Require sender access before allowing low-permission thread reopens

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 16, 2026
@shakkernerd
shakkernerd merged commit c0fc084 into main Sep 16, 2026
116 checks passed
@shakkernerd
shakkernerd deleted the fix/discord-reopen-permission branch September 16, 2026 19:19
@shakkernerd

Copy link
Copy Markdown
Contributor Author

Fixed: Discord channel actions can reopen accessible unlocked archived threads with Send Messages while preserving access and stronger-edit checks.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 17, 2026
Discord channel actions now classify the normalized edit payload before allowing an unlocked-thread reopen with Send Messages. Current visibility and private-thread membership are checked before the queued Discord PATCH, while every additional edit keeps the stronger permission path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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.

1 participant