Skip to content

Refactor stack trace formatter and add unit tests#2920

Merged
johnsimons merged 5 commits intofix/stacktrace-formatter-regexfrom
john/stack_tests
Mar 25, 2026
Merged

Refactor stack trace formatter and add unit tests#2920
johnsimons merged 5 commits intofix/stacktrace-formatter-regexfrom
john/stack_tests

Conversation

@johnsimons
Copy link
Member

Extract formatting logic from the Vue component into a dedicated TypeScript module to improve maintainability and enable unit testing. Includes a comprehensive test suite covering multiple languages and regression tests for exception message parsing.

Reviewer Checklist

  • Components are broken down into sensible and maintainable sub-components.
  • Styles are scoped to the component using it. If multiple components need to share CSS, then a .css file is created containing the shared CSS and imported into component scoped style sections.
  • Naming is consistent with existing code, and adequately describes the component or function being introduced
  • Only functions utilizing Vue state or lifecycle hooks are named as composables (i.e. starting with 'use');
  • No module-level state is being introduced. If so, request the PR author to move the state to the corresponding Pinia store.

Extract formatting logic from the Vue component into a dedicated TypeScript module to improve maintainability and enable unit testing. Includes a comprehensive test suite covering multiple languages and regression tests for exception message parsing.
The regex capture group always returns a string, but the interface
declared lineNumber as number. This caused a silent type lie that
the type assertion masked.
Splitting an empty string on ", " produces [""], resulting in a
bogus { type: "", name: undefined } param for no-argument methods.
Guard with a falsy check so params is an empty array instead.
The <StackTraceFrame> assertion bypassed structural checking, which
masked the lineNumber type mismatch. Using satisfies lets TypeScript
verify the object literal against the interface.
The regression comment incorrectly claimed 'at' matched inside words
like 'that'; the actual bug was an unanchored regex. The edge case
comment implied leading-whitespace was a fix when it was always the
existing behavior.
params: Array<{ name: string; type: string }>;
type: string;
lineNumber?: number;
lineNumber?: string;
Copy link
Member Author

Choose a reason for hiding this comment

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

@dvdstelt are you sure about this? Because currently, lineNumber is a number in the code in the main branch!

Copy link
Member Author

Choose a reason for hiding this comment

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

I see, you changed to use satisfies and hence the need to change this.
And it doesn't really make much of a difference.

@johnsimons johnsimons merged commit e6cdf9d into fix/stacktrace-formatter-regex Mar 25, 2026
3 of 5 checks passed
@johnsimons johnsimons deleted the john/stack_tests branch March 25, 2026 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants