Skip to content

fix: scrub raw error messages from error boundary before display#472

Merged
Priyanshu-byte-coder merged 1 commit into
Priyanshu-byte-coder:mainfrom
advikdivekar:fix/issue-452-raw-error-disclosure
May 21, 2026
Merged

fix: scrub raw error messages from error boundary before display#472
Priyanshu-byte-coder merged 1 commit into
Priyanshu-byte-coder:mainfrom
advikdivekar:fix/issue-452-raw-error-disclosure

Conversation

@advikdivekar
Copy link
Copy Markdown
Contributor

Summary

Closes #452

error.tsx rendered error.message directly inside a <code> block with no sanitisation. Any runtime error — Supabase constraint violations,
console.error(error) also fired unconditionally in the browser, including in production.

Changes

  • getSafeMessage(error) — new helper that:
    • Maps known error types (e.g. TokenRevoked) to user-friendly copy via SAFE_ERROR_MESSAGES
    • Returns a generic "An unexpected error occurred. Our team has been notified." in production for all other errors
    • Returns the raw message only in development (useful for debugging)
  • Raw <code> block removederror.message is no longer rendered in JSX; only getSafeMessage(error) is
  • error.digest surfaced — shown as "Error ID" when present, so support can correlate without leaking internals
  • console.error gated — only fires in non-production; a reportToSentry(error) hook comment is left for wiring up real error reporting

Test plan

  • Production mode: Supabase error "supabaseUrl is required." → shows generic message, not raw text
  • Production mode: DB constraint error "duplicate key value violates unique constraint '...'" → shows generic message
  • Production mode: TokenRevoked error → shows "Your GitHub session has expired. Please sign in again."
  • Development mode: TokenRevoked → same user-friendly mapping applies
  • Development mode: raw error message shown (debugging intact)
  • error.digest shown as Error ID when present (allows support correlation)
  • console.error not called in production (verified by gating on NODE_ENV !== "production")
  • npm run lint and npm run type-check pass with zero errors

error.tsx rendered error.message directly in a <code> block, leaking
Supabase constraint names, table names, and auth token details to any
user who hit a runtime error. Adds getSafeMessage() which returns a
generic message in production, maps known error types (TokenRevoked)
to user-friendly copy, and preserves the raw message only in
development. Also gates console.error behind NODE_ENV !== production
to avoid flooding browser consoles in prod. error.digest is still
surfaced for support correlation without exposing internals. Fixes Priyanshu-byte-coder#452
@vercel
Copy link
Copy Markdown

vercel Bot commented May 20, 2026

@advikdivekar is attempting to deploy a commit to the PRIYANSHU DOSHI's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added gssoc26 GSSoC 2026 contribution type:bug GSSoC type bonus: bug fix labels May 20, 2026
@github-actions
Copy link
Copy Markdown

GSSoC Label Checklist 🏷️

@Priyanshu-byte-coder — please apply the appropriate labels before merging:

Difficulty (pick one):

  • level:beginner — 20 pts
  • level:intermediate — 35 pts
  • level:advanced — 55 pts
  • level:critical — 80 pts

Quality (optional):

  • quality:clean — ×1.2 multiplier
  • quality:exceptional — ×1.5 multiplier

Validation (required to score):

  • gssoc:approved — counts for points
  • gssoc:invalid / gssoc:spam / gssoc:ai-slop — does not score

Type labels (type:*) are auto-detected from files and title. Review and adjust if needed.
Points formula: (difficulty × quality_multiplier) + type_bonus

@Priyanshu-byte-coder Priyanshu-byte-coder merged commit 306bd3a into Priyanshu-byte-coder:main May 21, 2026
4 checks passed
@Priyanshu-byte-coder Priyanshu-byte-coder added level:beginner GSSoC: Beginner difficulty (20 pts) gssoc:approved GSSoC: PR approved for scoring type:security GSSoC type bonus: security (+20 pts) labels May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved GSSoC: PR approved for scoring gssoc26 GSSoC 2026 contribution level:beginner GSSoC: Beginner difficulty (20 pts) type:bug GSSoC type bonus: bug fix type:security GSSoC type bonus: security (+20 pts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Critical : Raw Error Messages Exposed to Users

2 participants