Skip to content

Commit ff55bad

Browse files
committed
address CR comments
1 parent 12f5032 commit ff55bad

6 files changed

Lines changed: 38 additions & 38 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ Self-hosted Sentry users should opt out with `stream_gen_ai_spans=False`, since
6666

6767
- (test): exclude django 6.1 alphas and betas from tox by @ericapisani in [#6690](https://github.com/getsentry/sentry-python/pull/6690)
6868
- (test): need to include the alpha tag for mcp package inclusion by @ericapisani in [#6688](https://github.com/getsentry/sentry-python/pull/6688)
69+
6970
## 2.63.0
7071

7172
### Bug Fixes 🐛

sentry_sdk/_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ class SDKInfo(TypedDict):
153153
packages: "Sequence[Mapping[str, str]]"
154154

155155
class KeyValueCollectionBehaviour(TypedDict):
156-
mode: 'Literal["off", "deny_list", "allow_list"]'
156+
mode: 'Literal["off", "denylist", "allowlist"]'
157157
terms: "NotRequired[List[str]]"
158158

159159
class GenAICollectionUserOptions(TypedDict, total=False):

sentry_sdk/consts.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,6 +1451,8 @@ def __init__(
14511451
data_collection={"user_info": False, "http_bodies": []},
14521452
)
14531453
1454+
See https://docs.sentry.io/platforms/python/configuration/options/#data_collection for more details.
1455+
14541456
:param event_scrubber: Scrubs the event payload for sensitive information such as cookies, sessions, and
14551457
passwords from a `denylist`.
14561458

sentry_sdk/data_collection.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,26 @@
3737
KeyValueCollectionBehaviour,
3838
)
3939

40-
#: ``http_bodies`` defaults to this (collect everything the
41-
#: platform supports); an empty list is the explicit opt-out.
40+
# ``http_bodies`` defaults to this (collect everything the
41+
# platform supports); an empty list is the explicit opt-out.
42+
# response bodyies are not included here because we don't
43+
# currently capture them (as of Jul 7 2026)
4244
_ALL_HTTP_BODY_TYPES = [
4345
"incoming_request",
4446
"outgoing_request",
4547
]
4648

47-
#: Default number of source lines captured above and below a stack frame.
49+
# Default number of source lines captured above and below a stack frame.
4850
_DEFAULT_FRAME_CONTEXT_LINES = 5
4951

50-
#: Collection modes for key-value data (cookies, headers, query params).
51-
#: snake_case (Python-only deviation from the spec's camelCase); never
52-
#: serialized to Sentry.
53-
_VALID_KEY_VALUE_COLLECTION_BEHAVIOUR_MODES = ("off", "deny_list", "allow_list")
52+
# Collection modes for key-value data (cookies, headers, query params).
53+
# snake_case (Python-only deviation from the spec's camelCase); never
54+
# serialized to Sentry.
55+
_VALID_KEY_VALUE_COLLECTION_BEHAVIOUR_MODES = ("off", "denylist", "allowlist")
5456

55-
#: Values of keys that contain any of
56-
#: these terms (partial, case-insensitive) are always replaced with
57-
#: ``"[Filtered]"`` regardless of the configured collection mode.
57+
# Values of keys that contain any of
58+
# these terms (partial, case-insensitive) are always replaced with
59+
# ``"[Filtered]"`` regardless of the configured collection mode.
5860
_SENSITIVE_DENYLIST = [
5961
"auth",
6062
"token",
@@ -87,7 +89,7 @@ def _map_from_send_default_pii(
8789
``send_default_pii`` collects today. Used when ``data_collection`` is not
8890
provided explicitly.
8991
"""
90-
kv_mode: "Literal['deny_list', 'off']" = "deny_list" if send_default_pii else "off"
92+
kv_mode: "Literal['denylist', 'off']" = "denylist" if send_default_pii else "off"
9193
terms = [] if send_default_pii else ["forwarded", "-ip", "remote-", "via", "-user"]
9294

9395
return {
@@ -97,7 +99,7 @@ def _map_from_send_default_pii(
9799
# Headers are collected in both PII modes today (sensitive ones filtered
98100
# when PII is off), so this never maps to "off".
99101
"http_headers": {
100-
"request": {"mode": "deny_list", "terms": terms},
102+
"request": {"mode": "denylist", "terms": terms},
101103
},
102104
# Bodies are collected regardless of PII today, bounded by
103105
# ``max_request_body_size``.
@@ -163,7 +165,7 @@ def _resolve_explicit(
163165
def _kvcb_from_value(
164166
val: "dict[str, Any]",
165167
) -> "KeyValueCollectionBehaviour":
166-
mode = val.get("mode", "deny_list")
168+
mode = val.get("mode", "denylist")
167169
terms = val.get("terms", None)
168170

169171
if mode not in _VALID_KEY_VALUE_COLLECTION_BEHAVIOUR_MODES:
@@ -186,7 +188,7 @@ def _http_headers_from_value(
186188
"request": (
187189
_kvcb_from_value(val["request"])
188190
if "request" in val
189-
else _kvcb_from_value({"mode": "deny_list"})
191+
else _kvcb_from_value({"mode": "denylist"})
190192
),
191193
}
192194

sentry_sdk/scope.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2179,11 +2179,6 @@ def should_send_default_pii() -> bool:
21792179
return Scope.get_client().should_send_default_pii()
21802180

21812181

2182-
def get_data_collection() -> "DataCollection":
2183-
"""Return the resolved DataCollection config of the active client."""
2184-
return Scope.get_client().data_collection
2185-
2186-
21872182
# Circular imports
21882183
from sentry_sdk.client import NonRecordingClient
21892184

tests/test_data_collection.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ def test_kvcb_invalid_mode():
1212

1313

1414
def test_kvcb_from_dict_defaults_mode():
15-
sentry_sdk.init(data_collection={"cookies": {"mode": "deny_list", "terms": ["x"]}})
15+
sentry_sdk.init(data_collection={"cookies": {"mode": "denylist", "terms": ["x"]}})
1616
client = sentry_sdk.get_client()
1717
assert client.options["data_collection"]["cookies"] == {
18-
"mode": "deny_list",
18+
"mode": "denylist",
1919
"terms": ["x"],
2020
}
2121

@@ -26,19 +26,19 @@ def test_http_headers_collection_defaults():
2626
sentry_sdk.init(data_collection={"http_headers": {}}) # type: ignore Purposely ignoring to test invalid option
2727
client = sentry_sdk.get_client()
2828
assert client.options["data_collection"]["http_headers"]["request"] == {
29-
"mode": "deny_list"
29+
"mode": "denylist"
3030
}
3131

3232
sentry_sdk.init(data_collection={"http_headers": "off"}) # type: ignore Purposely ignoring to test invalid option
3333
client = sentry_sdk.get_client()
3434
assert client.options["data_collection"]["http_headers"]["request"] == {
35-
"mode": "deny_list"
35+
"mode": "denylist"
3636
}
3737

3838
sentry_sdk.init()
3939
client = sentry_sdk.get_client()
4040
assert client.options["data_collection"]["http_headers"]["request"] == {
41-
"mode": "deny_list",
41+
"mode": "denylist",
4242
"terms": default_terms,
4343
}
4444

@@ -47,15 +47,15 @@ def test_http_headers_use_default_in_setting_with_missing_config():
4747
sentry_sdk.init(
4848
data_collection={
4949
"http_headers": {
50-
"request": {"mode": "allow_list", "terms": ["x-id"]},
50+
"request": {"mode": "allowlist", "terms": ["x-id"]},
5151
}
5252
}
5353
)
5454

5555
client = sentry_sdk.get_client()
5656

5757
assert client.options["data_collection"]["http_headers"]["request"] == {
58-
"mode": "allow_list",
58+
"mode": "allowlist",
5959
"terms": ["x-id"],
6060
}
6161

@@ -83,7 +83,7 @@ def _get(dc, path):
8383
"gen_ai.outputs": False,
8484
"cookies.mode": "off",
8585
"query_params.mode": "off",
86-
"http_headers.request.mode": "deny_list",
86+
"http_headers.request.mode": "denylist",
8787
"http_bodies": _ALL_HTTP_BODY_TYPES,
8888
"frame_context_lines": 5,
8989
},
@@ -95,8 +95,8 @@ def _get(dc, path):
9595
"user_info": True,
9696
"gen_ai.inputs": True,
9797
"gen_ai.outputs": True,
98-
"cookies.mode": "deny_list",
99-
"query_params.mode": "deny_list",
98+
"cookies.mode": "denylist",
99+
"query_params.mode": "denylist",
100100
},
101101
id="send_default_pii_true_collects_pii",
102102
),
@@ -111,8 +111,8 @@ def _get(dc, path):
111111
"user_info": True,
112112
"gen_ai.inputs": True,
113113
"gen_ai.outputs": True,
114-
"cookies.mode": "deny_list",
115-
"query_params.mode": "deny_list",
114+
"cookies.mode": "denylist",
115+
"query_params.mode": "denylist",
116116
"http_bodies": _ALL_HTTP_BODY_TYPES,
117117
},
118118
id="explicit_data_collection_uses_spec_defaults",
@@ -123,7 +123,7 @@ def _get(dc, path):
123123
"user_info": False,
124124
"http_bodies": [],
125125
"gen_ai.inputs": True,
126-
"cookies.mode": "deny_list",
126+
"cookies.mode": "denylist",
127127
},
128128
id="explicit_partial_fills_omitted_with_spec_defaults",
129129
),
@@ -140,14 +140,14 @@ def _get(dc, path):
140140
{
141141
"data_collection": {
142142
"cookies": {"mode": "off"},
143-
"query_params": {"mode": "allow_list", "terms": ["page"]},
143+
"query_params": {"mode": "allowlist", "terms": ["page"]},
144144
"http_headers": {"request": {"mode": "off"}},
145145
"gen_ai": {"inputs": False, "outputs": True},
146146
}
147147
},
148148
{
149149
"cookies.mode": "off",
150-
"query_params.mode": "allow_list",
150+
"query_params.mode": "allowlist",
151151
"query_params.terms": ["page"],
152152
"http_headers.request.mode": "off",
153153
"gen_ai.inputs": False,
@@ -167,9 +167,9 @@ def _get(dc, path):
167167
}
168168
},
169169
{
170-
"cookies.mode": "deny_list",
171-
"http_headers.request.mode": "deny_list",
172-
"query_params.mode": "deny_list",
170+
"cookies.mode": "denylist",
171+
"http_headers.request.mode": "denylist",
172+
"query_params.mode": "denylist",
173173
"graphql.document": True,
174174
"graphql.variables": True,
175175
"gen_ai.inputs": True,

0 commit comments

Comments
 (0)