-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
ref(errors): Use enum for stacktrace order #96719
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
ref(errors): Use enum for stacktrace order #96719
Conversation
3f86b01
to
84ddde9
Compare
84ddde9
to
bb4db8b
Compare
bb4db8b
to
2753412
Compare
@@ -86,16 +93,19 @@ def get_context(lineno, context_line, pre_context=None, post_context=None): | |||
|
|||
|
|||
def is_newest_frame_first(event): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this function could return a StacktraceOrder
directly, there's no need to turn the enum into a boolean. Similarly, the newest_first
parameter of get_stacktrace
could then be a StacktraceOrder
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think those are both valid points, but my preference would be to address them in a follow-up PR, so that this one can remain solely about switching to using the enum. (Happy to add a TODO about it here, though, since it would make sense to address your points alongside addressing the Python-special-casing question.)
This is a follow-up to #96719, which added a backend `StacktraceOrder` enum, doing the same in the front end. It also clarifies the labels for the `Newest` (now `Newest first`) and `Oldest` (now `Oldest first`) options in user preferences.
2753412
to
66dadb4
Compare
Users can choose to display their stacktraces on the issue details page in reverse order, using the
stacktrace_order
user option. With a few caveats (see below), under the hood we store the option values as the strings"-1"
(default),"1"
(chronological order, with newest frame last), and"2"
(same as default, reverse chronological order, with newest frame first).* In the front end we use numbers instead of strings, but with corresponding values.Because the mapping is not obvious, this adds to the backend a
StacktraceOrder
enum (and a_SerializedStacktraceOrder
enum to handle the conversion to numbers), and uses them rather than the corresponding strings/numbers. A similar change for the front end will happen in a follow-up PR.Note: The description above is not strictly correct, for two reasons (each of which now has a corresponding TODO):
"2"
is not always the same as the default, or rather, the default behavior is not always to have the newest frame first. There is one place, (indirectly) in theStacktrace
interface'sto_string
method, where for Python events (and events with no platform, though practically speaking Relay normalization means there's always a platform) the default is the opposite, newest last. This doesn't match stacktrace ordering behavior anywhere else, so it might be worth investigating if we want to keep that special-casing in place. (It's also not immediately obvious where we (ultimately) use that method. Back when the special-casing was introduced (in late 2012), it was controlling the result ofStacktrace.to_html
, but now we obviously let react create the HTML, and in our current front end there's no such exception for Python.)