Repository navigation
chore: Remove include_local_variables, include_source_context
#7867
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
af5f129
deb4abb
b708f7f
ffb9b8d
092f9ab
e46f50c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -589,8 +589,6 @@ def filename_for_module( | |
| def serialize_frame( | ||
| frame: "FrameType", | ||
| tb_lineno: "Optional[int]" = None, | ||
| include_local_variables: bool = True, | ||
| include_source_context: bool = True, | ||
| max_value_length: "Optional[int]" = None, | ||
| custom_repr: "Optional[Callable[..., Optional[str]]]" = None, | ||
| ) -> "Dict[str, Any]": | ||
|
|
@@ -624,53 +622,38 @@ def serialize_frame( | |
| "lineno": tb_lineno, | ||
| } | ||
|
|
||
| client_options = sentry_sdk.get_client().options | ||
| if has_data_collection_enabled(client_options): | ||
| include_source_context = bool( | ||
| client_options["data_collection"]["frame_context_lines"] | ||
| ) | ||
| data_collection = sentry_sdk.get_client().options["data_collection"] | ||
|
|
||
| include_source_context = bool(data_collection["frame_context_lines"]) | ||
| if include_source_context: | ||
| rv["pre_context"], rv["context_line"], rv["post_context"] = get_source_context( | ||
| frame, tb_lineno, max_value_length | ||
| ) | ||
|
|
||
| if has_data_collection_enabled(client_options): | ||
| dc_stack_frame_vars_config = client_options["data_collection"][ | ||
| "stack_frame_variables" | ||
| ] | ||
| dc_stack_frame_vars_config = data_collection["stack_frame_variables"] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Frame serialization crashes without clientHigh Severity
Additional Locations (1)Reviewed by Cursor Bugbot for commit e46f50c. Configure here. |
||
|
|
||
| if isinstance(dc_stack_frame_vars_config, bool): | ||
| if dc_stack_frame_vars_config: | ||
| rv["vars"] = serialize( | ||
| dict(frame.f_locals), is_vars=True, custom_repr=custom_repr | ||
| ) | ||
| else: | ||
| local_variables_to_send = _apply_key_value_collection_filtering( | ||
| items=dict(frame.f_locals), | ||
| behaviour=dc_stack_frame_vars_config, | ||
| if isinstance(dc_stack_frame_vars_config, bool): | ||
| if dc_stack_frame_vars_config: | ||
| rv["vars"] = serialize( | ||
| dict(frame.f_locals), is_vars=True, custom_repr=custom_repr | ||
| ) | ||
| else: | ||
| local_variables_to_send = _apply_key_value_collection_filtering( | ||
| items=dict(frame.f_locals), | ||
| behaviour=dc_stack_frame_vars_config, | ||
| ) | ||
|
|
||
| if local_variables_to_send: | ||
| serialized_variables = serialize( | ||
| local_variables_to_send, is_vars=True, custom_repr=custom_repr | ||
| ) | ||
|
|
||
| rv["vars"] = serialized_variables | ||
| if local_variables_to_send: | ||
| serialized_variables = serialize( | ||
| local_variables_to_send, is_vars=True, custom_repr=custom_repr | ||
| ) | ||
|
|
||
| elif include_local_variables: | ||
| rv["vars"] = serialize( | ||
| dict(frame.f_locals), is_vars=True, custom_repr=custom_repr | ||
| ) | ||
| rv["vars"] = serialized_variables | ||
|
|
||
| return rv | ||
|
|
||
|
|
||
| def current_stacktrace( | ||
| include_local_variables: bool = True, | ||
| include_source_context: bool = True, | ||
| max_value_length: "Optional[int]" = None, | ||
| ) -> "Dict[str, Any]": | ||
| def current_stacktrace(max_value_length: "Optional[int]" = None) -> "Dict[str, Any]": | ||
| __tracebackhide__ = True | ||
| frames = [] | ||
|
|
||
|
|
@@ -680,8 +663,6 @@ def current_stacktrace( | |
| frames.append( | ||
| serialize_frame( | ||
| f, | ||
| include_local_variables=include_local_variables, | ||
| include_source_context=include_source_context, | ||
| max_value_length=max_value_length, | ||
| ) | ||
| ) | ||
|
|
@@ -770,22 +751,16 @@ def single_exception_from_error_tuple( | |
| exception_value["value"] = get_error_message(exc_value) | ||
|
|
||
| if client_options is None: | ||
| include_local_variables = True | ||
| include_source_context = True | ||
| max_value_length = None # fallback | ||
| custom_repr = None | ||
| else: | ||
| include_local_variables = client_options["include_local_variables"] | ||
| include_source_context = client_options["include_source_context"] | ||
| max_value_length = client_options["max_value_length"] | ||
| custom_repr = client_options.get("custom_repr") | ||
|
|
||
| frames: "List[Dict[str, Any]]" = [ | ||
| serialize_frame( | ||
| tb.tb_frame, | ||
| tb_lineno=tb.tb_lineno, | ||
| include_local_variables=include_local_variables, | ||
| include_source_context=include_source_context, | ||
| max_value_length=max_value_length, | ||
| custom_repr=custom_repr, | ||
| ) | ||
|
|
@@ -1176,7 +1151,6 @@ def event_from_exception( | |
|
|
||
| if client_options and client_options.get("add_full_stack", DEFAULT_ADD_FULL_STACK): | ||
| full_stack = current_stacktrace( | ||
| include_local_variables=client_options["include_local_variables"], | ||
| max_value_length=client_options["max_value_length"], | ||
| )["frames"] | ||
| else: | ||
|
|
||


Uh oh!
There was an error while loading. Please reload this page.