Skip to content

Commit 8c711b3

Browse files
committed
address bot comment
1 parent b48ea28 commit 8c711b3

2 files changed

Lines changed: 40 additions & 8 deletions

File tree

sentry_sdk/data_collection.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,13 @@ def _resolve_explicit(
151151
return {
152152
"provided_by_user": True,
153153
"user_info": d.get("user_info", True),
154-
"cookies": _kvcb_from_value(d.get("cookies", {})),
155-
"http_headers": _http_headers_from_value(d.get("http_headers", {})),
154+
"cookies": _kvcb_from_value(d.get("cookies") or {}),
155+
"http_headers": _http_headers_from_value(d.get("http_headers") or {}),
156156
"http_bodies": http_bodies,
157-
"query_params": _kvcb_from_value(d.get("query_params", {})),
158-
"graphql": _graphql_from_value(d.get("graphql", {})),
159-
"gen_ai": _gen_ai_from_value(d.get("gen_ai", {})),
160-
"database": _database_from_value(d.get("database", {})),
157+
"query_params": _kvcb_from_value(d.get("query_params") or {}),
158+
"graphql": _graphql_from_value(d.get("graphql") or {}),
159+
"gen_ai": _gen_ai_from_value(d.get("gen_ai") or {}),
160+
"database": _database_from_value(d.get("database") or {}),
161161
"stack_frame_variables": stack_frame_variables,
162162
"frame_context_lines": frame_context_lines,
163163
}
@@ -234,8 +234,16 @@ def resolve_data_collection(options: "Dict[str, Any]") -> "DataCollection":
234234
user_dc = options.get("data_collection")
235235
send_default_pii = options.get("send_default_pii")
236236

237-
include_local_variables = options.get("include_local_variables", True)
238-
include_source_context = options.get("include_source_context", True)
237+
include_local_variables = (
238+
bool(options.get("include_local_variables"))
239+
if options.get("include_local_variables") is not None
240+
else True
241+
)
242+
include_source_context = (
243+
bool(options.get("include_source_context"))
244+
if options.get("include_source_context") is not None
245+
else True
246+
)
239247

240248
if user_dc is not None:
241249
if not isinstance(user_dc, dict):

tests/test_data_collection.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,30 @@ def _get(dc, path):
189189
},
190190
id="accepts_dict_with_nested_dicts",
191191
),
192+
pytest.param(
193+
{
194+
"data_collection": {
195+
"cookies": None,
196+
"http_headers": None,
197+
"query_params": None,
198+
"graphql": None,
199+
"gen_ai": None,
200+
"database": None,
201+
}
202+
},
203+
{
204+
"cookies.mode": "deny_list",
205+
"http_headers.request.mode": "deny_list",
206+
"http_headers.response.mode": "deny_list",
207+
"query_params.mode": "deny_list",
208+
"graphql.document": True,
209+
"graphql.variables": True,
210+
"gen_ai.inputs": True,
211+
"gen_ai.outputs": True,
212+
"database.query_params": True,
213+
},
214+
id="none_values_fall_back_to_spec_defaults",
215+
),
192216
pytest.param(
193217
{"data_collection": {}},
194218
{

0 commit comments

Comments
 (0)