Skip to content

fix(discord): message edit, delete and pin fail after one lost response - #169806

Merged
obviyus merged 2 commits into
openclaw:mainfrom
ericcurtin:fix/discord-message-mutation-retry
Oct 12, 2026
Merged

obviyus merged 2 commits into
openclaw:mainfrom
ericcurtin:fix/discord-message-mutation-retry

Conversation

@ericcurtin

@ericcurtin ericcurtin commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Closes #127536

What Problem This Solves

Fixes: Discord message edit, delete, pin and unpin fail after one transient error or lost response, while reactions retry.

User Impact

User impact: these actions recover from transient Discord errors. A delete that was applied but lost its response reports success, not Unknown Message. A caller that aborts during backoff stops retrying right away.

Why This Change Was Made

They now use the same per-request retry runner as reactions. Delete treats code 10008 as done only after an earlier attempt failed with a lost response. createDiscordClient passes the caller's signal to that runner, so abort interrupts backoff.

Evidence

Trace through the production helpers (editMessageDiscord, pinMessageDiscord, unpinMessageDiscord, deleteMessageDiscord) and the real RequestClient against a loopback HTTP server that plays Discord (no tokens, no external hosts):

edit:   PATCH  /v10/channels/111/messages/222 -> 502
        PATCH  /v10/channels/111/messages/222 -> 200      resolved, 2 requests
pin:    PUT    /v10/channels/111/pins/222     -> 502
        PUT    /v10/channels/111/pins/222     -> 200      resolved, 2 requests
unpin:  DELETE /v10/channels/111/pins/222     -> 502
        DELETE /v10/channels/111/pins/222     -> 200      resolved, 2 requests
delete: DELETE /v10/channels/111/messages/222 -> 502
        DELETE /v10/channels/111/messages/222 -> 200      resolved, 2 requests
delete, applied but response lost:
        DELETE /v10/channels/111/messages/222 -> applied, connection dropped
        DELETE /v10/channels/111/messages/222 -> 404 code 10008   resolved {ok:true}
delete, Unknown Message on the first attempt:
        DELETE /v10/channels/111/messages/222 -> 404 code 10008   rejected, 1 request
delete, caller aborts 100ms into a 2s backoff:
        DELETE /v10/channels/111/messages/222 -> 502              rejected "caller aborted" after 102ms, 1 request
  • pnpm test extensions/discord/src/send.sends-basic-channel-messages.test.ts --maxWorkers=1: 58 passed, 69s. The new retry and abort tests fail without the fix.
  • pnpm test:extension discord: 251 files, 2683 passed.
  • pnpm tsgo:extensions, pnpm tsgo:extensions:test, oxlint and oxfmt are clean.
  • The checks above are contributor-reported; independent validation is recorded below.
  • CI: the only red is test/scripts/eager-import-closure.test.ts, which also fails on pure main (12a91e0919, 08005517c4) and on unrelated PRs. This PR does not touch it.

Independent validation on 3d51c5f96c7e229b7c36a0c9e894feebed21cd96

  • Production mutation helpers with the real Discord RequestClient against a loopback HTTP fault server: all four actions recover from a 502 in two requests. Baseline 59aa506fe82e8c88ac2265330af00f25267521cc rejects each after one request.
  • Applied delete with a lost response: head retries, accepts subsequent code 10008, and resolves; baseline reports fetch failed. First-attempt 10008 remains an error. Abort during a two-second backoff stops head after one request (62 ms). Persistent 502 uses exactly the configured three attempts.
  • Pin/unpin also recover after an applied mutation loses its response. Captured requests are bodyless PUT / DELETE to /v10/channels/111/pins/222. Both use exactly three attempts for persistent 502, and abort during backoff after one request (75 ms / 193 ms). Baseline sends only one request and reports failure for 502 and lost responses.
  • Real Discord via the QA Lab isolated Gateway: doctor passed; a run-owned message was sent, edited through the production helper, read back, and deleted sequentially during cleanup. Recorder observed create/update/delete, and cleanup reported no unresolved operations or failures.
  • Only live coverage gap: the leased QA bot lacks Manage Messages permission. Discord rejected pin with Missing Permissions; live pin/unpin could not be completed. No permissions were changed and no credential rotation was attempted. Pin/unpin transport recovery is covered by the production-client fault matrix above.
  • Independent focused test: pnpm test extensions/discord/src/send.sends-basic-channel-messages.test.ts --maxWorkers=1 — 58 passed (31.33 s runner wall time). Changed-file oxfmt and oxlint passed. Contributor code ran only in isolated Docker.
  • Inherited CI confirmed against unrelated PR #169028's job: the exact same eager-import-closure.test.ts case fails at line 173 with duplicate src/config/sessions/transcript-entry-anchor.ts. This PR's failing job has the same assertion. Aggregate CI remains red; no jobs were rerun.

Thanks to @ericcurtin for the fix and @steipete for the report. No overlap with Pash/Sarah changes.

Merge risk: two-way door; reverting restores the former retry behavior without migrating configuration or stored state. Blast radius is Discord message edit/delete/pin/unpin recovery and callers cancelling Discord retry backoff. Non-idempotent message sends retain the existing retry-safety owner.

@clawsweeper

clawsweeper Bot commented Oct 12, 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 docs Improvements or additions to documentation channel: discord Channel integration: discord size: S labels Oct 12, 2026
@clawsweeper clawsweeper Bot added 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. labels Oct 12, 2026
@clawsweeper

clawsweeper Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Discord message edits, deletes, pins, and unpins use the existing retry runner, including cancellation and already-applied delete recovery.

Example: Deleting message 222 in channel 111 succeeds at Discord, but the response connection drops.

  • Before: The action reports failure despite the message being deleted.
  • After: A retry returning Discord code 10008 resolves successfully.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A useful, focused repair with sufficient real-transport boundary evidence, meaningful regression coverage, and no remaining findings.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): Recorded production-helper and real RequestClient traces against a loopback HTTP server demonstrate recovery for all four mutations, applied-delete response loss, first-attempt 10008 rejection, and cancellation during backoff; this satisfies the transport-fault proof rule without claiming live Discord coverage.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Discord reports edit, delete, pin, or unpin failure after one transient error, even when the mutation was applied.
Reason: The linked owner-authored issue requests this exact bounded repair, and every production hunk serves its recovery or cancellation contract.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current Discord retry bypass with a focused patch and no actionable correctness findings; the observed CI fixture failure also occurs on unrelated work.

Priority: P2
Reviewed head: 3d51c5f96c7e229b7c36a0c9e894feebed21cd96

Before merge

None.

Findings

None.

Agent review details

How this fits together

Discord action dispatch passes account-scoped mutations to production send helpers, which use the retry runner and REST client to return confirmed results or errors.

flowchart LR
  A[Discord message action] --> B[Mutation helper]
  B --> C[Account scoped retry runner]
  C --> D[REST client]
  D --> E[Current authority checks]
  E --> F[Discord HTTP endpoint]
  F --> D
  D --> C
Loading

Technical review

Best possible solution:

Land the existing focused repair through the normal workflow with inherited CI failures handled under repository policy.

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

Current-main source exposes the direct-call failure path, and the contributor supplies production-client HTTP traces; this read-only review executed no target code.

Is this the best way to solve the issue?

Reusing the existing per-request owner is the narrow repair, with cancellation preserved and delete success normalization restricted to an earlier ambiguous attempt.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Discord mutation helper ownership changes intended behavior with a stated reason (7e16a22: The consolidation preserved existing transport behavior; the linked issue separately identifies direct mutation calls as a retry bypass.)
  • Account-scoped retry client keeps the original intent (da0103f: Reconnect recovery belongs at the individual REST-request boundary rather than whole-delivery replay.)
  • Discord semantic error parsing keeps the original intent (20163ee: Recognize specific Discord codes while preserving unrelated HTTP failures; the extracted reader preserves voice-state behavior and adds an exact message-code predicate.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 267f1ad adds extensions/discord/src/client.ts:153 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 267f1ad9173f; files: extensions/discord/src/client.ts)
  • tiffanychum: Raw commit da0103f adds extensions/discord/src/client.ts:154 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: da0103f02544; files: extensions/discord/src/client.ts)
  • Shadow: Raw commit 6bab813 adds src/discord/send.test.ts:315 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: low; commits: 6bab813bb3a6; files: src/discord/send.test.ts)

PR surface

Source +40, Tests +110, Docs +1. Total +151 across 6 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 4 57 17 +40
Tests 1 110 0 +110
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 168 17 +151

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #127536
Summary: This PR implements the canonical mutation-retry repair; the merged scheduled-write repair addresses separate authorization behavior.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: A bounded reliability repair restores four existing Discord mutations after transient transport failures.
  • 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.
  • 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 (2 earlier review cycles)
  • reviewed 2026-10-12T09:52:36.603Z sha a3bb6e1 :: needs real behavior proof before merge. :: [P2] Forward the caller's abort signal into mutation retry backoff
  • reviewed 2026-10-12T12:22:14.415Z sha 3d51c5f :: needs maintainer review before merge. :: none

Reviewed October 12, 2026, 8:49 AM ET / 12:49 UTC (Revision 3).

@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: 🧂 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. labels Oct 12, 2026
@obviyus

obviyus commented Oct 12, 2026

Copy link
Copy Markdown
Collaborator

Maintainer override: the only red job is checks-node-compact-small-3, failing eager-import-closure.test.ts:173 on a duplicate src/config/sessions/transcript-entry-anchor.ts entry. The same test and assertion fail on an unrelated PR (https://github.com/openclaw/openclaw/actions/runs/38246940545/job/114803546576). This PR changes only Discord message mutation retries, their tests and the retry docs. ClawSweeper is ready on this exact head with no findings.

@obviyus
obviyus merged commit 37aefbf into openclaw:main Oct 12, 2026
131 of 135 checks passed
@obviyus

obviyus commented Oct 12, 2026

Copy link
Copy Markdown
Collaborator

Landed in 37aefbf. Thanks @ericcurtin, Discord edits, deletes and pins now survive transient failures.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 13, 2026
…se (openclaw#169806)

Discord message edit, delete, pin and unpin bypassed the Discord retry owner, so one transient error (for example a 502) or a lost response failed the action. They now go through the existing retry owner. A delete whose first attempt succeeded but whose response was lost succeeds when the retry gets 10008 Unknown Message; a 10008 on the first attempt still fails. Persistent failures stop after the configured attempts, and cancellation stops the backoff. Proof: production helpers and the real RequestClient against a loopback fault server. On main all four mutations failed after one request on a 502; with the PR they succeeded after a retry, and the lost-response delete and pin/unpin cases recovered. Real Discord QA Lab on the PR: send, edit with readback, and delete. Live pin/unpin was not run because the QA bot lacks Manage Messages; the loopback proof covers those requests. Fixes openclaw#127536. Thanks @ericcurtin.

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

Labels

channel: discord Channel integration: discord docs Improvements or additions to documentation 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: 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.

Discord edit, delete, pin, and unpin bypass the channel retry owner

2 participants