Skip to content

feat(pii): add data collection for stack frame variables - #2194

Open
Litarnus wants to merge 1 commit into
collect-request-informationfrom
frame-data-collection
Open

feat(pii): add data collection for stack frame variables#2194
Litarnus wants to merge 1 commit into
collect-request-informationfrom
frame-data-collection

Conversation

@Litarnus

@Litarnus Litarnus commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Adds data collection support for stack variables

Comment on lines +50 to +54
$options = $client->getOptions();
$dataCollection = $options->getDataCollection();
$maxContextLines = $dataCollection === null
? $options->getContextLines()
: $dataCollection->getFrameContextLines();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: When data_collection is enabled, setting context_lines: null is ignored, and context lines are still collected using the default value of 5.
Severity: LOW

Suggested Fix

The logic should respect context_lines: null even when data_collection is enabled. The check for $options->getContextLines() being null should take precedence. If it is null, then $maxContextLines should be set to null to disable context line collection, regardless of the data_collection settings.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: src/Integration/FrameContextifierIntegration.php#L50-L54

Potential issue: When a user configures `data_collection` and also sets `context_lines`
to `null` with the intention of disabling stack trace context lines, the setting is
ignored. The logic in `FrameContextifierIntegration` incorrectly prioritizes the
`data_collection` configuration for context lines. The method `getFrameContextLines()`
from `DataCollectionOptions` always returns an integer (defaulting to 5) and never
`null`. This prevents the `$maxContextLines === null` check from ever being true,
causing context lines to be collected against the user's explicit configuration.

Did we get this right? 👍 / 👎 to inform future reviews.

@Litarnus
Litarnus force-pushed the frame-data-collection branch from fa17a2b to c29854a Compare September 4, 2026 13:00
Comment thread src/FrameBuilder.php
$dataCollection = $this->options->getDataCollection();

if ($dataCollection !== null) {
$argumentValues = KeyValueDataFilter::filterKeyValueData(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

KeyValueDataFilter::filterKeyValueData() is a recursive function. But $argumentValues could include recursive arrays, which causes KeyValueDataFilter::filterKeyValueData() to recurse until the memory limit is exceeded.

For example:

$foo['recursion'] =& $foo;
\Sentry\DataCollection\KeyValueDataFilter::filterKeyValueData($foo, ['mode' => 'on', 'terms' => []]);

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.

2 participants