Skip to content

fix(sentry): gate includeLocalVariables and drop sendDefaultPii#2710

Merged
Marfuen merged 2 commits intomainfrom
mariano/sentry-gate-local-vars
Apr 29, 2026
Merged

fix(sentry): gate includeLocalVariables and drop sendDefaultPii#2710
Marfuen merged 2 commits intomainfrom
mariano/sentry-gate-local-vars

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot commented Apr 29, 2026

Summary

Two related tightenings of Sentry server-side data exposure, prompted by cubic.dev review on PR #2707.

1. Gate includeLocalVariables to non-production

The Sentry SDK uses Node's debugger inspector to attach every local variable in scope at the moment an error throws. In production that scope can include DB rows, auth tokens being validated, request bodies, and session state — broader than sendDefaultPii. Off in prod, on in dev/test where the debugging value justifies it.

includeLocalVariables: process.env.NODE_ENV !== 'production',

2. Drop sendDefaultPii entirely

Originally added on the assumption it would unblur replay text — it doesn't. Replay masking is controlled by replayIntegration({ maskAllText, blockAllMedia }) (handled in PR #2709). With replays already showing real text, all sendDefaultPii adds is per-event IP and User-Agent. Useful triage signal, but not worth the sub-processor data exposure for a compliance product.

What still works without it:

  • Stack traces (source-mapped)
  • Breadcrumbs / SDK-captured request URLs
  • Replays with real text
  • Whatever you pass to Sentry.setUser({ id }) explicitly

What goes away:

  • Per-event request.ip_address
  • User-Agent / Referer headers
  • Some auto-attached request metadata (already had default scrubbers for Cookie / Authorization)

Files

apps/{app,portal}/sentry.server.config.ts, apps/{app,portal}/sentry.edge.config.ts, apps/{app,portal}/src/instrumentation-client.ts

Test plan

  • Vercel preview build succeeds for app and portal
  • Trigger a server error on the preview, confirm the event in Sentry has a stack trace but no request.ip_address field
  • Trigger a client error, confirm replay still records (and shows readable text)

🤖 Generated with Claude Code

includeLocalVariables uses Node's debugger inspector to attach every
local variable in scope at the moment an error throws. In production
that scope can include DB rows, auth tokens being validated, request
bodies, and session state — far broader than sendDefaultPii. Off in
prod, on in dev/test where the debugging value justifies the exposure.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
app Ready Ready Preview, Comment Apr 29, 2026 9:30pm
comp-framework-editor Ready Ready Preview, Comment Apr 29, 2026 9:30pm
portal Ready Ready Preview, Comment Apr 29, 2026 9:30pm

Request Review

…knob

sendDefaultPii was originally added to make session replay text
readable, but that's actually controlled by replayIntegration's
maskAllText / blockAllMedia (handled in #2709). With replays already
showing real text, the only thing sendDefaultPii adds is per-event IP
addresses and User-Agent — useful triage signal but not worth the
sub-processor data exposure for a compliance product.

Errors still carry full stack traces, breadcrumbs, source-mapped
frames, and replay context; only the IP/UA metadata layer goes away.
Removing across all six init files (server, edge, client × app, portal).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Marfuen Marfuen changed the title [dev] [Marfuen] mariano/sentry-gate-local-vars fix(sentry): gate includeLocalVariables and drop sendDefaultPii Apr 29, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files

Auto-approved: Security hardening of Sentry configuration to prevent accidental PII/sensitive data exposure in production stack traces. Low-risk monitoring config change.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

0 issues found across 6 files (changes from recent commits).

Auto-approved: Safe configuration changes to Sentry that improve data privacy by gating local variables and removing default PII collection in production.

@Marfuen Marfuen merged commit e985b8b into main Apr 29, 2026
7 of 10 checks passed
@Marfuen Marfuen deleted the mariano/sentry-gate-local-vars branch April 29, 2026 21:25
claudfuen pushed a commit that referenced this pull request Apr 29, 2026
# [3.38.0](v3.37.0...v3.38.0) (2026-04-29)

### Bug Fixes

* **sentry:** gate includeLocalVariables and drop sendDefaultPii ([#2710](#2710)) ([e985b8b](e985b8b)), closes [#2709](#2709)

### Features

* **observability:** integrate Sentry into app and portal ([#2705](#2705)) ([0aa2417](0aa2417))
@claudfuen
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 3.38.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants