Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
extract isExceptionGroup helper
  • Loading branch information
Lms24 committed Jan 28, 2026
commit f9cb9eed57e505b4d062b44dc212f4357860fa1c
8 changes: 6 additions & 2 deletions packages/core/src/utils/aggregate-errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function aggregateExceptionsFromError(

// This will create exception grouping for AggregateErrors
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AggregateError
if (Array.isArray(error.errors)) {
if (isExceptionGroup(error)) {
error.errors.forEach((childError, i) => {
if (isInstanceOf(childError, Error)) {
applyExceptionGroupFieldsForParentException(exception, exceptionId, error);
Expand All @@ -98,6 +98,10 @@ function aggregateExceptionsFromError(
return newExceptions;
}

function isExceptionGroup(error: ExtendedError): error is ExtendedError & { errors: unknown[] } {
return Array.isArray(error.errors);
}

function applyExceptionGroupFieldsForParentException(
exception: Exception,
exceptionId: number,
Expand All @@ -106,7 +110,7 @@ function applyExceptionGroupFieldsForParentException(
exception.mechanism = {
handled: true,
type: 'auto.core.linked_errors',
...(Array.isArray(error.errors) && { is_exception_group: true }),
...(isExceptionGroup(error) && { is_exception_group: true }),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Order change allows mechanism to override is_exception_group

Low Severity

The spread order in applyExceptionGroupFieldsForParentException changed from setting is_exception_group: true AFTER ...exception.mechanism to BEFORE it. Previously, the flag would always override for exception groups. Now, if exception.mechanism already contains an is_exception_group value (even false), it will override the duck-typed detection. This could cause exception groups to be incorrectly classified if a custom exceptionFromErrorImplementation sets is_exception_group in the mechanism.

Fix in Cursor Fix in Web

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah but I think this is actually more correct. Theoretically users could set this beforehand and I don't think it hurts us to flip this in the default case. Gonna leave it as-is.

...exception.mechanism,
exception_id: exceptionId,
};
Expand Down
Loading