Skip to content

fix: Stop per-context private attributes from leaking between contexts - #416

Draft
kinyoklion wants to merge 1 commit into
mainfrom
devin/1786660571-private-attribute-leak
Draft

fix: Stop per-context private attributes from leaking between contexts#416
kinyoklion wants to merge 1 commit into
mainfrom
devin/1786660571-private-attribute-leak

Conversation

@kinyoklion

Copy link
Copy Markdown
Member

Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions

Related issues

Found while investigating the contract test failures fixed in #415. Not covered by the current contract test suite.

Describe the solution you've provided

ContextFilter#filter_single_context combined the globally configured private attributes with the context's own _meta.privateAttributes using Array#concat, which mutates @private_attributes in place. Every context filtered by a ContextFilter therefore permanently added its private attributes to the filter's configuration, so a context's private attributes were applied to all contexts filtered afterwards — including the other kinds of the same multi-kind context.

Before (single ContextFilter.new(false, [])):

filter.filter(user_with_private_email)  # {..., _meta: {redactedAttributes: [:email]}}
filter.filter(other_user)               # {..., _meta: {redactedAttributes: [:email]}}  <- email was not private here

The fix builds a new array (@private_attributes + context.private_attributes) instead of mutating the configured list. Event processors reuse a single ContextFilter for the lifetime of the client, so the leak was cumulative across all events.

Describe alternatives you've considered

Constructing the filter per event — unnecessary allocation churn, and the mutation is the actual defect.

Additional context

Full contract test suite against harness v3.2.0-alpha.6 passes with this change (combined with #415): 4723 total, 14 skipped, all ran passed.

Link to Devin session: https://app.devin.ai/sessions/316afaccd2604f8d802a72c9080f6921
Requested by: @kinyoklion

Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
@kinyoklion kinyoklion self-assigned this Aug 13, 2026
@devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration

Copy link
Copy Markdown
Contributor

@cursor review

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant