Repository navigation
fix(discord): prevent REST failures from exposing credentials - #116805
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 31, 2026, 6:28 PM ET / 22:28 UTC. ClawSweeper reviewWhat this changesThe PR sanitizes Discord REST failure diagnostics and replaces retained rate-limit and webhook-token identifiers with stable hashes so reflected credentials are not exposed without changing retry grouping. Merge readinessThe patch is a coherent repair for a current Discord credential-retention path and the final maintainer amendment closes the remaining webhook scheduler-key leak. No actionable correctness finding surfaced; keep this PR open while a maintainer refreshes the interrupted exact-head lint/check set before merge. Priority: P1 Review scores
Verification
How this fits togetherDiscord’s REST client turns unsuccessful API responses into error objects used by normal sends, webhooks, voice messages, and rate-limit scheduling. This patch changes the boundary where response diagnostics and route identities are retained before they reach retry state or operator-visible errors. flowchart LR
A[Discord REST response] --> B[Discord request client]
B --> C[Error and rate-limit parsing]
C --> D[Credential redaction boundary]
D --> E[Sanitized error diagnostics]
D --> F[Stable hashed bucket identity]
F --> G[Rate-limit scheduler]
G --> H[Retry grouping]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +181, Tests +281. Total +462 across 4 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one shared redaction boundary for retained Discord REST failures, retain stable hashed scheduler identifiers for bucket correlation, and merge only after the refreshed exact-head checks confirm the final behavior. Do we have a high-confidence way to reproduce the issue? Yes—source inspection shows current main retains the parsed failed response as Is this the best way to solve the issue? Yes—the shared DiscordError construction boundary is the narrowest maintainable owner for sanitizing all REST failure consumers, and the paired scheduler-route hashing addresses the adjacent retained webhook-token identity without changing successful requests. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 5620ea7c57d6. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (6 earlier review cycles)
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Author-side follow-up is complete on exact head 0cc4e400157dc2a8352819587a1a3d6ab9333ec1. ClawSweeper now marks the proof sufficient, rates the PR platinum, and reports no actionable finding. Fresh CI run 30646600130 passed every job except check-lint and its downstream ci-gate. The lint log contains no diagnostic: the hosted runner received a shutdown signal while oxlint was running and exited 143. This is the second current-head run with the same infrastructure termination; the full implementation head previously passed check-lint, and the only subsequent source change removes an unused export. Contributor credentials cannot invoke the upstream rerun API. Maintainer action requested: rerun the failed jobs on run 30646600130. No further author-side code or proof change is indicated. |
0cc4e40 to
292f0a5
Compare
|
Maintainer review update for exact head
Discord contract: https://docs.discord.com/developers/topics/rate-limits @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Final maintainer closeout for exact head
Ready for the final maintainer merge decision. |
What Problem This Solves
Discord REST failures could retain credentials reflected by Discord or an intermediary in error messages, structured response bodies, rate-limit headers, and scheduler diagnostic keys. Those values flow through the shared REST client used by normal sends, interaction webhooks, command deployment, and voice-message requests.
Why This Change Was Made
The repair is owned at the shared Discord REST boundary:
DiscordErrorsanitizes bounded text and structured diagnostics before retainingmessage,rawBody, orrawError.user,global, orsharedvalues.This is the best owner boundary because every REST failure consumer receives the same sanitized object and scheduler grouping stays deterministic without caller-specific cleanup.
Discord contract: https://docs.discord.com/developers/topics/rate-limits
User Impact
Operators can inspect Discord REST failures and scheduler metrics without reflected bot or webhook credentials being retained. Successful requests, Discord error classification, retry timing, and route-to-bucket grouping remain unchanged.
Evidence
Production-path proof
The focused test starts a real loopback HTTP server and sends a synthetic credential through production
RequestClient. The server reflects it through:X-RateLimit-BucketandX-RateLimit-Scope/webhooks/{id}/{token}routeAssertions prove the credential is absent from retained errors and scheduler metrics, Discord codes and retry metadata remain available, repeated webhook requests retain stable bucket grouping, and successful responses are unchanged.
Final head
292f0a5a6f519f1b94cb8ba1f73ee4b6e0d84128383363e3623374db34c2b855f52f244caa688998.292f0a5a6f51closes the sibling webhook scheduler-key leak found during deep review.849dde12d0d0b16792ab5e8032bb37dab1afcf01: no touched-path drift since the branch base; clean merge treea21c179399d2d4c9e0611c91f2d5c5f6b997e583.Validation
oxfmt --check, plugin boundary, max-lines ratchet, conflict-marker, import-cycle, diff, and secret scans: passed.Blacksmith Testbox's delegated command channel hung before producing test output on two fresh leases. Per repository fallback policy, the full focused proof ran in the trusted checkout; hosted exact-head CI is the independent remote gate.
Not tested: a real bot credential against Discord's public service. The proof deliberately uses a synthetic credential through the production client so no live secret is exposed.
AI Assistance
This change was developed with AI assistance. The author and maintainer reviewed the code, tests, and evidence and remain responsible for the contribution.