feat(pii): add data collection for stack frame variables - #2194
Conversation
| $options = $client->getOptions(); | ||
| $dataCollection = $options->getDataCollection(); | ||
| $maxContextLines = $dataCollection === null | ||
| ? $options->getContextLines() | ||
| : $dataCollection->getFrameContextLines(); |
There was a problem hiding this comment.
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.
fa17a2b to
c29854a
Compare
| $dataCollection = $this->options->getDataCollection(); | ||
|
|
||
| if ($dataCollection !== null) { | ||
| $argumentValues = KeyValueDataFilter::filterKeyValueData( |
There was a problem hiding this comment.
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' => []]);
Adds data collection support for stack variables