Skip to content

fix: restore sanitized Sentry browser error delivery - #1611

Draft
jaywedgeworth22 wants to merge 11 commits into
mainfrom
codex/sentry-error-delivery
Draft

jaywedgeworth22 wants to merge 11 commits into
mainfrom
codex/sentry-error-delivery

Conversation

@jaywedgeworth22

@jaywedgeworth22 jaywedgeworth22 commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator

Diagnosis

The 14-day Sentry audit found 32 error-category client discards, all network_error, and no accepted errors; spans/logs/check-ins were active. Production CSP omitted Sentry. This confirms a browser transport block consistent with the failures, but does not prove every discard had the same cause.

Changes

  • Add only the validated HTTPS intake origin derived from the existing public Sentry DSN. No wildcard, custom port, or credentials in CSP; existing Datadog intake stays.
  • Use matching browser/server/edge hooks, including v11 streamed spans and a final envelope guard for scope values appended after ordinary hooks.
  • Project events and wire rows to explicit diagnostic/operational fields. Drop caller extra and unknown contexts; remove uncontrolled messages, request URLs/query values, user data, prompts and credential bags.
  • Preserve allowlisted error classes, numeric stack locations, approved generated chunk identifiers, curated health labels/counters and known runtime metrics. Arbitrary function/module/source text and paths are removed.
  • Preserve typed SDK attribute schemas and no-inference metadata; reject malformed containers/scalars and opaque recordings/attachments. Replay stays off; sampling is unchanged.
  • Bound work with single-event and aggregate-envelope node/character budgets calibrated against real SDK buffers. Unsafe rows produce non-sensitive before_send discard counters.

Diagnostic tradeoff

Strict privacy intentionally removes free-form exception messages and most stack filename/function labels. This reduces source-map resolution and grouping/detail for errors whose locations are not approved generated chunk identifiers. Error class, stack row order, line/column, trace/release metadata and approved operational counters remain. This is a tested bounded telemetry policy, not a claim of universal PII detection or historical exposure clearance.

Verification at 519c29c

  • Local production build, typecheck, lint (13 existing warnings), and 99 tests across nine files passed.
  • Fresh independent review passed final scrubber SHA256 d6d4d06d00a062e67b47579d4ab5bfab92b46fe44599eafb525f0821949d52e2.
  • Real Node/Browser SDK in-memory transports verify sanitized class/stack errors with tracing off, a 100-breadcrumb/60-frame error, 100 logs, 1000 metrics and 1001 parent/child spans, typed schemas and exact discard counts.
  • Regression probes cover late scope data, encoded query keys, credential/prompt/custom-context bags, malformed containers, repeated graphs, sparse arrays and oversized strings.
  • Exact-head hosted database/coverage tests (247 files), migration/backup checks, Docker build/smoke, CodeQL, gitleaks and pin checks passed. Required verify failed only at dependency audit: unchanged sharp is flagged by GHSA-wq5f-xc86-pv6w. This gate is not waived; dependency remediation is separate. Kody's latest review is still running.
  • Live SHA/CSP and accepted Sentry receipt remain unverified rollout gates. No production synthetic incident or real user payload was sent.

Coordination / task notes

SDK/CSP/privacy scope is separate from reporter PRs #1610/#1612. This PR remains draft while separate rollout/reporter gates are held. Owner approved narrow Sentry CSP rollout, independent-review/CI substitution while Codex bot quota is exhausted, and evidence-based Kody responses. Owner also approved code/tests-only publication with these task notes: prepared AGENTS.md/effort-log edits are excluded because their upload is blocked. No private history or new credentials are included. Board reservation remains in progress until rollout is verified.

Current candidate df84a46

Integrated the separately merged sharp security patch. This candidate passes 110 scoped tests, typecheck and local build plus independent actual-SDK review. The final guard permits only error/transaction/span/log/metric/check-in/client-report envelopes; feedback, session summaries and unknown payload types are intentionally excluded. Check-in and client-report fields are projected; all 13 installed SDK discard reasons remain usable. Errors receive priority within the bounded aggregate budget and item failures preserve sanitized siblings. Private http.route values cannot bypass the route allowlist.

Current-head hosted CI/review is running; earlier-head verification above is historical. The de1 hostname suggestion remains explicitly unresolved pending authoritative supported-host evidence; network validation has not been broadened. No live privacy rollout or synthetic production error has occurred.

Feedback UI correction: Sentry feedback registration is disabled. Report a Problem uses the existing user-initiated mailto fallback with unchanged recipient/subject; the actual Nav handler is tested. No automatic email is sent. Check-in projection now reuses the scheduler's existing pure configuration helper to prevent cadence drift. These changes passed focused independent review and local build/typecheck; exact-head hosted CI/review must finish before landing.

Final batched collector alignment (2712522)

Profiling sample rate is zero and the installed BrowserSession integration is disabled, matching the explicit envelope policy. Profiling and crash-free session metrics are unavailable; normal approved errors and performance telemetry remain. Other default integrations are preserved. Synthetic report-button fixtures replace production origins, and missing CSP has an explicit test failure. Local scoped tests, typecheck/lint/build and narrow independent review passed; current-head hosted checks remain the final validation. No review configuration or sampling increase is introduced.

@kody-ai

kody-ai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ✅

Access your configuration settings here.

​

@jaywedgeworth22
jaywedgeworth22 marked this pull request as ready for review October 6, 2026 12:07
@kody-ai

kody-ai Bot commented Oct 6, 2026

Copy link
Copy Markdown

kody code-review Kody Rules medium

Consumer entry-point mismatch in Vitest arises because tests import the added or modified Sentry utilities directly from internal modules while src/index.ts omits their exports. Export the utilities from src/index.ts and route their Vitest imports through that entry point so the tested surface matches the package consumer surface.

Kody rule violation: Every exported schema or utility ships with tests and must typecheck

@kody-ai

kody-ai Bot commented Oct 6, 2026

Copy link
Copy Markdown

kody code-review Kody Rules medium

Prose-spacing violation: the agent-written doc comment separates its two sentences with one literal ASCII space instead of the two required by the repository-wide prose spacing rule.

Kody rule violation: Use two spaces between sentences in every human-facing string and agent-written paragraph

@kody-ai

kody-ai Bot commented Oct 6, 2026

Copy link
Copy Markdown

kody code-review Business Logic medium

🤔 Insufficient Task Context

I found a task linked to this PR, but it only contains minimal information (title only, no description or acceptance criteria). To perform a meaningful business rules validation, I need more details.

🔍 What I need to validate:

  • Business requirements and acceptance criteria
  • Expected behavior and business rules
  • Edge cases and constraints to consider

💡 How to improve the task context:

  • Add a description to the linked ticket
  • Include acceptance criteria or business rules
  • Describe the expected behavior after the change

⚠️ Important:

A task title alone is not sufficient to determine whether the implementation is correct or complete.


💡 This validation runs automatically only on the first review of a pull request. To run it again, comment @kody -v business-logic.

Comment thread src/lib/sentry-options.ts
Comment thread src/lib/sentry-scrubber.ts Outdated
Comment thread src/lib/sentry-scrubber.ts Outdated
@kody-ai

kody-ai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ✅

Access your configuration settings here.

​

@kody-ai

kody-ai Bot commented Oct 6, 2026

Copy link
Copy Markdown

kody code-review Business Logic medium

🤔 Insufficient Task Context

I found a task linked to this PR, but it only contains minimal information (title only, no description or acceptance criteria). To perform a meaningful business rules validation, I need more details.

🔍 What I need to validate:

  • Business requirements and acceptance criteria
  • Expected behavior and business rules
  • Edge cases and constraints to consider

💡 How to improve the task context:

  • Add a description to the linked ticket
  • Include acceptance criteria or business rules
  • Describe the expected behavior after the change

⚠️ Important:

A task title alone is not sufficient to determine whether the implementation is correct or complete.


💡 This validation runs automatically only on the first review of a pull request. To run it again, comment @kody -v business-logic.

Comment thread src/lib/sentry-scrubber.ts
Comment thread src/lib/sentry-scrubber.ts Outdated
@kody-ai

kody-ai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ✅

Access your configuration settings here.

​

@jaywedgeworth22
jaywedgeworth22 marked this pull request as draft October 6, 2026 12:54
@kody-ai

kody-ai Bot commented Oct 6, 2026

Copy link
Copy Markdown

kody code-review Kody Rules medium

Runtime type-validation gap at the SDK boundary: casting an arbitrary string to never suppresses the required envelope-item type check before envelopeItemTypeToDataCategory. Make reportDrop accept type as unknown, validate it against SDK-supported envelope-item types, and omit the event when dataCategoryForEnvelopeItemType returns no category.

Kody rule violation: Keep type safety and test coverage for source changes

@kody-ai

kody-ai Bot commented Oct 6, 2026

Copy link
Copy Markdown

kody code-review Kody Rules critical

Credential exposure occurs because the test commits a Sentry DSN containing a key-like username, project ID, and intake endpoint that the rule cannot exempt as synthetic. Inject a non-production DSN through SENTRY_TEST_DSN and fail clearly when it is absent.

Kody rule violation: Never hardcode secrets or tokens in web or Swift sources

@kody-ai

kody-ai Bot commented Oct 6, 2026

Copy link
Copy Markdown

kody code-review Business Logic medium

🤔 Insufficient Task Context

I found a task linked to this PR, but it only contains minimal information (title only, no description or acceptance criteria). To perform a meaningful business rules validation, I need more details.

🔍 What I need to validate:

  • Business requirements and acceptance criteria
  • Expected behavior and business rules
  • Edge cases and constraints to consider

💡 How to improve the task context:

  • Add a description to the linked ticket
  • Include acceptance criteria or business rules
  • Describe the expected behavior after the change

⚠️ Important:

A task title alone is not sufficient to determine whether the implementation is correct or complete.


💡 This validation runs automatically only on the first review of a pull request. To run it again, comment @kody -v business-logic.

Comment thread src/lib/sentry-scrubber.ts
Comment thread src/lib/sentry-scrubber.ts
Comment thread src/lib/sentry-scrubber.ts
Comment thread src/lib/sentry-scrubber.ts
Comment thread src/lib/sentry-scrubber.ts Outdated
@kody-ai

kody-ai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ✅

Access your configuration settings here.

​

@kody-ai

kody-ai Bot commented Oct 6, 2026

Copy link
Copy Markdown

kody code-review Business Logic medium

🤔 Insufficient Task Context

I found a task linked to this PR, but it only contains minimal information (title only, no description or acceptance criteria). To perform a meaningful business rules validation, I need more details.

🔍 What I need to validate:

  • Business requirements and acceptance criteria
  • Expected behavior and business rules
  • Edge cases and constraints to consider

💡 How to improve the task context:

  • Add a description to the linked ticket
  • Include acceptance criteria or business rules
  • Describe the expected behavior after the change

⚠️ Important:

A task title alone is not sufficient to determine whether the implementation is correct or complete.


💡 This validation runs automatically only on the first review of a pull request. To run it again, comment @kody -v business-logic.

Comment thread src/lib/sentry-scrubber.ts Outdated
Comment thread src/lib/sentry-scrubber.ts Outdated
Comment thread src/lib/sentry-scrubber.ts Outdated
@kody-ai

kody-ai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ✅

Access your configuration settings here.

​

@kody-ai

kody-ai Bot commented Oct 7, 2026

Copy link
Copy Markdown

kody code-review Business Logic medium

🤔 Insufficient Task Context

I found a task linked to this PR, but it only contains minimal information (title only, no description or acceptance criteria). To perform a meaningful business rules validation, I need more details.

🔍 What I need to validate:

  • Business requirements and acceptance criteria
  • Expected behavior and business rules
  • Edge cases and constraints to consider

💡 How to improve the task context:

  • Add a description to the linked ticket
  • Include acceptance criteria or business rules
  • Describe the expected behavior after the change

⚠️ Important:

A task title alone is not sufficient to determine whether the implementation is correct or complete.


💡 This validation runs automatically only on the first review of a pull request. To run it again, comment @kody -v business-logic.

Comment thread src/lib/__tests__/sentry-scrubber.test.ts
Comment thread src/lib/sentry-scrubber.ts
Comment thread src/lib/sentry-scrubber.ts
Comment thread src/lib/sentry-scrubber.ts Outdated
@kody-ai

kody-ai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ✅

Access your configuration settings here.

​

@kody-ai

kody-ai Bot commented Oct 7, 2026

Copy link
Copy Markdown

kody code-review Business Logic medium

🤔 Insufficient Task Context

I found a task linked to this PR, but it only contains minimal information (title only, no description or acceptance criteria). To perform a meaningful business rules validation, I need more details.

🔍 What I need to validate:

  • Business requirements and acceptance criteria
  • Expected behavior and business rules
  • Edge cases and constraints to consider

💡 How to improve the task context:

  • Add a description to the linked ticket
  • Include acceptance criteria or business rules
  • Describe the expected behavior after the change

⚠️ Important:

A task title alone is not sufficient to determine whether the implementation is correct or complete.


💡 This validation runs automatically only on the first review of a pull request. To run it again, comment @kody -v business-logic.

Comment thread src/components/ReportProblemButton.test.ts Outdated
Comment thread src/components/ReportProblemButton.test.ts Outdated
Comment thread src/components/ReportProblemButton.test.ts Outdated
Comment thread src/lib/__tests__/sentry-delivery.test.ts Outdated
Comment thread src/lib/sentry-scrubber.ts
@kody-ai

kody-ai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ✅

Access your configuration settings here.

​

@kody-ai

kody-ai Bot commented Oct 7, 2026

Copy link
Copy Markdown

kody code-review Business Logic medium

🤔 Insufficient Task Context

I found a task linked to this PR, but it only contains minimal information (title only, no description or acceptance criteria). To perform a meaningful business rules validation, I need more details.

🔍 What I need to validate:

  • Business requirements and acceptance criteria
  • Expected behavior and business rules
  • Edge cases and constraints to consider

💡 How to improve the task context:

  • Add a description to the linked ticket
  • Include acceptance criteria or business rules
  • Describe the expected behavior after the change

⚠️ Important:

A task title alone is not sufficient to determine whether the implementation is correct or complete.


💡 This validation runs automatically only on the first review of a pull request. To run it again, comment @kody -v business-logic.

Comment thread src/lib/sentry-scrubber.ts
Comment thread src/lib/sentry-scrubber.ts
Comment thread src/lib/sentry-scrubber.ts Outdated
@kody-ai

kody-ai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ✅

Access your configuration settings here.

​

@kody-ai

kody-ai Bot commented Oct 7, 2026

Copy link
Copy Markdown

kody code-review Business Logic medium

🤔 Insufficient Task Context

I found a task linked to this PR, but it only contains minimal information (title only, no description or acceptance criteria). To perform a meaningful business rules validation, I need more details.

🔍 What I need to validate:

  • Business requirements and acceptance criteria
  • Expected behavior and business rules
  • Edge cases and constraints to consider

💡 How to improve the task context:

  • Add a description to the linked ticket
  • Include acceptance criteria or business rules
  • Describe the expected behavior after the change

⚠️ Important:

A task title alone is not sufficient to determine whether the implementation is correct or complete.


💡 This validation runs automatically only on the first review of a pull request. To run it again, comment @kody -v business-logic.

Comment thread src/lib/sentry-scrubber.ts

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant