Skip to content

feat(data-collection): create DataCollection option in client#6702

Draft
ericapisani wants to merge 20 commits into
masterfrom
ep/db-spec-experiement-foundation-dict
Draft

feat(data-collection): create DataCollection option in client#6702
ericapisani wants to merge 20 commits into
masterfrom
ep/db-spec-experiement-foundation-dict

remove accessor methods

12f5032
Select commit
Loading
Failed to load commit list.
@sentry/warden / warden: code-review completed Jul 6, 2026 in 0s

3 issues

code-review: Found 3 issues (1 medium, 2 low)

Medium

`get_data_collection()` raises AttributeError — no `.data_collection` attribute exists on any client class - `sentry_sdk/scope.py:2184`

get_data_collection() in scope.py accesses Scope.get_client().data_collection, but no data_collection property or attribute is defined on BaseClient, NonRecordingClient, or _Client; the resolved value lives at self.options["data_collection"]. There is no __getattr__ fallback, so any call to this helper will raise AttributeError. The helper is currently unused (the PR notes the option is not yet hooked up), so this is a latent bug that will surface on first use.

Low

DeprecationWarning for `send_default_pii` uses stacklevel=2 that points to SDK internals, not user code - `sentry_sdk/client.py:28`

The warnings.warn(..., stacklevel=2) in _resolve_data_collection (data_collection.py:248) will attribute the warning to the direct caller of _resolve_data_collection_get_options() in client.py:353 — rather than the user's sentry_sdk.init() call, making the DeprecationWarning non-actionable. The actual user call chain is deeper: init() -> Client()/_Client.init -> get_options()/_get_options -> _resolve_data_collection, so the stacklevel would need to account for the full chain to point to user code.

Also found at:

  • sentry_sdk/client.py:352
  • sentry_sdk/data_collection.py:250-253
`_http_headers_from_value` uses substring check instead of dict key check, causing inconsistent behavior for invalid inputs - `sentry_sdk/data_collection.py:188-190`

The "request" in val check on line 188 performs a Python substring test when val is a string, not a dict-key lookup. The existing test passes "off" and works only by coincidence ("off" contains no "request" substring); a value like "request_headers" would satisfy the in check and then val["request"] would raise a confusing TypeError: string indices must be integers rather than a clear validation error — while the sibling _kvcb_from_value raises AttributeError for the same class of invalid input.

Also found at:

  • tests/test_data_collection.py:32-36

⏱ 8m 5s · 3.4M in / 97.9k out · $3.79

Annotations

Check warning on line 2184 in sentry_sdk/scope.py

See this annotation in the file changed.

@sentry-warden sentry-warden / warden: code-review

`get_data_collection()` raises AttributeError — no `.data_collection` attribute exists on any client class

`get_data_collection()` in scope.py accesses `Scope.get_client().data_collection`, but no `data_collection` property or attribute is defined on `BaseClient`, `NonRecordingClient`, or `_Client`; the resolved value lives at `self.options["data_collection"]`. There is no `__getattr__` fallback, so any call to this helper will raise `AttributeError`. The helper is currently unused (the PR notes the option is not yet hooked up), so this is a latent bug that will surface on first use.