Skip to content

fix(discord): prevent credentials from appearing in non-JSON errors - #119536

Merged
Patrick-Erichsen merged 2 commits into
openclaw:mainfrom
Alix-007:alix/oc-t24-10-discord-error-body-redaction
Aug 6, 2026
Merged

Patrick-Erichsen merged 2 commits into
openclaw:mainfrom
Alix-007:alix/oc-t24-10-discord-error-body-redaction

Conversation

@Alix-007

@Alix-007 Alix-007 commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

AI-assisted: This change was implemented and validated with Codex.

Additional instructions

MUST: Keep Allow edits from maintainers enabled for this PR so maintainers
can help update the branch when needed.

What Problem This Solves

Fixes an issue where users troubleshooting Discord API failures could see a bot credential in surfaced error details when a proxy or upstream reflected the request authorization in either JSON or non-JSON output.

Why This Change Was Made

Discord error details now pass through the shared forced tool-payload redactor at the final formatting boundary used by both JSON and text responses. Existing normalization, response limits, rate-limit behavior, and HTTP status reporting remain intact.

User Impact

Discord failures retain their status and useful non-sensitive diagnostic text without exposing a reflected bot token.

Evidence

  • Public exact-head run: Discord runtime proof checked out and verified 2bf546d413f736cc647162b48aab36ddff1d3679.
  • Downloadable terminal artifact: openclaw-discord-2bf546d413f736cc647162b48aab36ddff1d3679.
  • node scripts/run-vitest.mjs extensions/discord/src/api.test.ts --reporter=verbose — 1 file, 21 tests passed through the real loopback requestDiscord path.
  • Sanitized after-fix terminal output (the synthetic credential is never printed):
[discord credential redaction proof] format=html status=502 authorization_received=true token_present=false unique_fragment_present=false
[discord credential redaction proof] format=json status=429 authorization_received=true token_present=false unique_fragment_present=false retry_after=0
proof_marker_verified=true
  • Targeted oxfmt --check, oxlint, and git diff --check passed for the touched files.

@openclaw-barnacle openclaw-barnacle Bot added channel: discord Channel integration: discord size: XS labels Aug 5, 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. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Aug 5, 2026
@clawsweeper

clawsweeper Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 5, 2026, 7:07 AM ET / 11:07 UTC.

ClawSweeper review

What this changes

The PR redacts reflected credentials from Discord JSON and non-JSON API error summaries while preserving status and retry diagnostics.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open: current main still inserts unredacted upstream JSON or text error detail into Discord errors, while this focused PR applies the existing forced redactor at both affected Discord boundaries with aligned loopback proof.

Priority: P1
Reviewed head: 2bf546d413f736cc647162b48aab36ddff1d3679

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused owner-boundary security repair with exact-head loopback proof and no actionable review finding.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR body supplies exact-head loopback terminal proof for reflected HTML and JSON credentials, showing redaction while preserving status and retry diagnostics.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body supplies exact-head loopback terminal proof for reflected HTML and JSON credentials, showing redaction while preserving status and retry diagnostics.
Evidence reviewed 7 items Current-main exposure: Current main selects an upstream JSON message or text/HTML summary and appends it directly to DiscordApiError without redaction.
Canonical redaction contract: The public plugin SDK redactor forces tools-mode defaults even if ordinary logging redaction is disabled, and its tests cover Authorization: Bot values.
Sibling diagnostic path: Gateway metadata sends the bot Authorization header and includes the shared response summary in its thrown error and fallback log, so the error-body change closes a distinct consumer.
Findings None None.
Security None None.

How this fits together

The Discord plugin makes authenticated REST requests and turns failed upstream responses into diagnostics for operators and agents. Response text flows through the error formatter or gateway metadata summary before becoming an error or fallback log.

flowchart LR
A[Authenticated Discord request] --> B[Upstream error response]
B --> C[Response parser and HTML summary]
C --> D[Discord error formatter]
C --> E[Gateway metadata fallback]
D --> F[Shared credential redactor]
E --> F
F --> G[Visible diagnostic or log]
Loading

Before merge

  • Resolve merge risk (P1) - The branch is behind current main; GitHub reports it mergeable, so required checks should validate the final merge result before landing.
  • Complete next step (P2) - No repair lane is needed: this is a coherent external implementation awaiting routine maintainer review and exact-merge-result checks.
Agent review details

Security

None.

PR surface

Source +9, Tests +80. Total +89 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 2 11 2 +9
Tests 1 80 0 +80
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 91 2 +89

Review metrics

Metric Value Why it matters
Production vs test LOC production +11/-2; tests +80/-0 The small production increase is justified by two credential-redaction boundaries; the larger test addition exercises both response shapes through the real loopback request path.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land the focused owner-plugin repair after the exact merge result is green, keeping the forced shared redactor as the single boundary for untrusted Discord diagnostics.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Land the focused owner-plugin repair after the exact merge result is green, keeping the forced shared redactor as the single boundary for untrusted Discord diagnostics.

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

Yes: current source shows untrusted response detail reaching DiscordApiError without redaction, and the PR provides an exact-head loopback reproduction for HTML and JSON reflections; untrusted contributor code was not run locally.

Is this the best way to solve the issue?

Yes: the final formatter covers both JSON and text REST errors, while the shared summary change protects the separate gateway-metadata diagnostic consumer without adding a parallel policy.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: Reflected Discord bot credentials can reach operator-visible diagnostics on an existing channel workflow.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; 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. Sufficient (terminal): The PR body supplies exact-head loopback terminal proof for reflected HTML and JSON credentials, showing redaction while preserving status and retry diagnostics.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies exact-head loopback terminal proof for reflected HTML and JSON credentials, showing redaction while preserving status and retry diagnostics.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Blame attributes the current formatter and summary code to the merged Discord-area refactor, and local history shows the largest sampled contribution count in these files. (role: current Discord runtime feature owner; confidence: high; commits: 2692954c72aa; files: extensions/discord/src/api.ts, extensions/discord/src/error-body.ts)
  • Vincent Koc: History identifies the earlier bounded Discord API-error-body change, adjacent to the shared error path this repair extends. (role: prior API-error-body contributor; confidence: medium; commits: 698efb23a648; files: extensions/discord/src/api.ts, extensions/discord/src/error-body.ts)
  • Alix-007: History includes an earlier requestDiscord response-body hardening change, in addition to the proposed repair. (role: prior Discord API hardening contributor; confidence: medium; commits: fca15641dba5; files: extensions/discord/src/api.ts, extensions/discord/src/api.test.ts)

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 (4 earlier review cycles)
  • reviewed 2026-08-05T07:38:40.097Z sha ffb1366 :: needs real behavior proof before merge. :: [P1] Redact JSON error messages at the shared formatter boundary
  • reviewed 2026-08-05T08:41:11.281Z sha 2bf546d :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-05T09:06:44.207Z sha 2bf546d :: needs maintainer review before merge. :: none
  • reviewed 2026-08-05T09:13:14.152Z sha 2bf546d :: needs maintainer review before merge. :: none

@Alix-007

Alix-007 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the JSON sibling path and added public exact-head runtime proof to the PR body: https://github.com/Alix-007/openclaw/actions/runs/30989854767\n\n@clawsweeper re-review

@Alix-007

Alix-007 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@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. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. 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. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Aug 5, 2026
@Patrick-Erichsen Patrick-Erichsen self-assigned this Aug 6, 2026

@Patrick-Erichsen Patrick-Erichsen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved at exact head 2bf546d. No blocking findings. The Discord owner boundary now applies the canonical forced redactor to reflected JSON and non-JSON API details while preserving status and retry diagnostics; exact-head loopback proof and required CI are green.

@Patrick-Erichsen
Patrick-Erichsen merged commit ab74723 into openclaw:main Aug 6, 2026
138 of 150 checks passed
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 6, 2026
…penclaw#119536)

* fix(discord): redact non-JSON API error details

* fix(discord): redact JSON API error details
steipete added a commit to zenglingbiao/openclaw that referenced this pull request Aug 27, 2026
Bind bounded error diagnostics to the actual outgoing request headers for
shared web tools and both Perplexity transports. Preserve caller cancellation
and replace case-insensitive owned headers without combining credentials.

Reuse the provider error redactor and remove duplicate xAI parser-only test
paths while retaining real HTTP and sibling coverage. Production -18 lines;
total -14 lines including regression tests and documentation.

Refs openclaw#120200, openclaw#117304, openclaw#119536.

Co-authored-by: zenglingbiao <[email protected]>
steipete added a commit that referenced this pull request Aug 27, 2026
…and reason phrase (#120200)

* fix(web): redact request credentials from provider errors

Bind bounded error diagnostics to the actual outgoing request headers for
shared web tools and both Perplexity transports. Preserve caller cancellation
and replace case-insensitive owned headers without combining credentials.

Reuse the provider error redactor and remove duplicate xAI parser-only test
paths while retaining real HTTP and sibling coverage. Production -18 lines;
total -14 lines including regression tests and documentation.

Refs #120200, #117304, #119536.

Co-authored-by: zenglingbiao <[email protected]>

* fix(tooling): install managed signals before spawning children

Prevent early SIGTERM from orphaning a detached compiler before its supervisor
registers the child. Retain shared handlers for concurrent commands and clean
them up after synchronous or asynchronous spawn failure.

Reproduce the race at the real process boundary and consolidate stale type
comments and one-use registration wrappers.

---------

Co-authored-by: Peter Steinberger <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 28, 2026
…and reason phrase (openclaw#120200)

* fix(web): redact request credentials from provider errors

Bind bounded error diagnostics to the actual outgoing request headers for
shared web tools and both Perplexity transports. Preserve caller cancellation
and replace case-insensitive owned headers without combining credentials.

Reuse the provider error redactor and remove duplicate xAI parser-only test
paths while retaining real HTTP and sibling coverage. Production -18 lines;
total -14 lines including regression tests and documentation.

Refs openclaw#120200, openclaw#117304, openclaw#119536.

Co-authored-by: zenglingbiao <[email protected]>

* fix(tooling): install managed signals before spawning children

Prevent early SIGTERM from orphaning a detached compiler before its supervisor
registers the child. Retain shared handlers for concurrent commands and clean
them up after synchronous or asynchronous spawn failure.

Reproduce the race at the real process boundary and consolidate stale type
comments and one-use registration wrappers.

---------

Co-authored-by: Peter Steinberger <[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 P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor 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.

2 participants