Skip to content

fix: redact RPC tokens from logged deal errors#453

Merged
rjan90 merged 5 commits into
mainfrom
phi/fix-errors-leakage
Apr 16, 2026
Merged

fix: redact RPC tokens from logged deal errors#453
rjan90 merged 5 commits into
mainfrom
phi/fix-errors-leakage

Conversation

@rjan90
Copy link
Copy Markdown
Contributor

@rjan90 rjan90 commented Apr 16, 2026

What changed

  • redact sensitive credentials from URLs embedded in structured error messages and stacks
  • persist a redacted deal failure message instead of the raw upstream error text
  • add regression tests covering log serialization and failed deal persistence

Why

A 429 from the configured Filecoin RPC can bubble up through viem with the full request URL in the error message. Dealbot was forwarding that raw message into logs and into deals.error_message, which could expose RPC query-string tokens.

Impact

This keeps the existing error flow intact while replacing values for sensitive URL credentials and query parameters like token, api_key, apikey, access_token, and authorization with REDACTED in the affected dealbot surfaces.

Root cause

viem includes the full request URL in HttpRequestError / ContractFunctionExecutionError messages, and dealbot was serializing and persisting error.message without any redaction.

Validation

  • pnpm test -- logging.spec.ts deal.service.spec.ts (backend suite passed)
  • pnpm typecheck

@FilOzzy FilOzzy added this to FOC Apr 16, 2026
@github-project-automation github-project-automation Bot moved this to 📌 Triage in FOC Apr 16, 2026
@rjan90 rjan90 changed the title [codex] redact RPC tokens from logged deal errors fix: redact RPC tokens from logged deal errors Apr 16, 2026
@rjan90 rjan90 requested review from SgtPooki and silent-cipher and removed request for silent-cipher April 16, 2026 06:28
@rjan90 rjan90 self-assigned this Apr 16, 2026
@rjan90 rjan90 moved this from 📌 Triage to 🔎 Awaiting review in FOC Apr 16, 2026
@rjan90 rjan90 marked this pull request as ready for review April 16, 2026 06:28
@silent-cipher silent-cipher requested a review from Copilot April 16, 2026 07:01
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Redacts sensitive RPC credentials (e.g., query-string tokens) from error strings that end up in logs and persisted deal failure messages.

Changes:

  • Added URL-based redaction utilities and applied them to toStructuredError (message/stack/string throws).
  • Persist a redacted deal.errorMessage when deal creation fails.
  • Added regression tests for URL redaction and deal failure persistence.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
apps/backend/src/deal/deal.service.ts Redacts persisted deal failure message before saving.
apps/backend/src/deal/deal.service.spec.ts Adds test ensuring persisted failure message is redacted.
apps/backend/src/common/logging.ts Introduces URL redaction and applies it to structured error serialization.
apps/backend/src/common/logging.spec.ts Adds tests covering redaction across message/stack/cause and string throws.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread apps/backend/src/common/logging.ts Outdated
Comment thread apps/backend/src/common/logging.ts Outdated
Comment thread apps/backend/src/common/logging.ts Outdated
Copy link
Copy Markdown
Contributor

@rvagg rvagg left a comment

Choose a reason for hiding this comment

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

sgtm but the copilot suggestion is important to fix before merging

Comment thread apps/backend/src/common/logging.ts Outdated
rjan90 and others added 3 commits April 16, 2026 12:26
Co-authored-by: Rod Vagg <rod@vagg.org>
Co-authored-by: Rod Vagg <rod@vagg.org>
@github-project-automation github-project-automation Bot moved this from 🔎 Awaiting review to ✔️ Approved by reviewer in FOC Apr 16, 2026
@rjan90 rjan90 merged commit 77cac85 into main Apr 16, 2026
7 checks passed
@rjan90 rjan90 deleted the phi/fix-errors-leakage branch April 16, 2026 12:04
@github-project-automation github-project-automation Bot moved this from ✔️ Approved by reviewer to 🎉 Done in FOC Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🎉 Done

Development

Successfully merging this pull request may close these issues.

6 participants