-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
ref(grouping): Change exception subcomponent order in grouping info #102281
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
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 |
|---|---|---|
|
|
@@ -406,6 +406,22 @@ def __init__( | |
| def key(self) -> str: | ||
| return _get_exception_component_key(self) | ||
|
|
||
| def as_dict(self) -> dict[str, Any]: | ||
| """ | ||
| Convert to a dictionary, first rearranging the values so they show up in the order we want | ||
| in grouping info. | ||
| """ | ||
| ordered_values: Any = [] | ||
|
|
||
| for component_id in ["type", "value", "ns_error", "stacktrace"]: | ||
| subcomponent = self.get_subcomponent(component_id) | ||
| if subcomponent: | ||
| ordered_values.append(subcomponent) | ||
|
|
||
| self.values = ordered_values | ||
|
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. You know more about grouping than I do — and I'll defer to your expertise — but I worry that we might be dropping some values here. Instead could we just do: This would order everything in-place, preserve items with duplicate IDs, and not drop things with unexpected IDs. 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. In an abstract sense you're right, but it's not an issue here because exception components can only ever have one copy of any given subcomponent type. (This mirrors the fact that a given error only ever is of one type, only ever has a single error message, etc. Yes, there can be chained exceptions, but each exception in the chain still only has a single type/value/stacktrace/etc.) This is also only a temporary work-around, to get us from the universe where we do 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. Coolio, I'll approve — there is a plan to change the original values order (and then we can remove this method)? 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. Yup, that's what these two parts in the description were trying to say:
and
|
||
|
|
||
| return super().as_dict() | ||
|
|
||
|
|
||
| class ChainedExceptionGroupingComponent(BaseGroupingComponent[ExceptionGroupingComponent]): | ||
| id: str = "chained_exception" | ||
|
|
||
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.
Nit: I am concerned about the hardcoded list of values not being future-proofed... but recognize that this is a pretty small class definition and we'd probably notice. Still, I think my other suggestion will address this.