-
Notifications
You must be signed in to change notification settings - Fork 191
Implement aggressive stack trace normalization for better error grouping #6120
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
base: main
Are you sure you want to change the base?
Conversation
This change significantly improves how errors are grouped in our telemetry system by normalizing environment-specific paths in stack traces. Key improvements: - Fix critical security vulnerabilities: * Sanitize path traversal sequences (../ and ./) * Add input validation with 1000 char length limit * Preserve Windows drive letters as <DRIVE_C>, <DRIVE_D> etc - Fix correctness bugs: * UUID pattern now matches anywhere in path (not just between slashes) * Version pattern now matches at end of paths without trailing slash - Add comprehensive path normalizations: * Home directories → <HOME> * Temp directories → <TEMP> * Global package managers → <GLOBAL_NPM>, <GLOBAL_YARN>, <GLOBAL_PNPM> * Webpack chunks → chunk-<HASH>.js * CI/CD environments → <CI_WORKSPACE> * Container paths → <CONTAINER> * Version numbers → @<VERSION> * UUIDs → <UUID> - Add 56 comprehensive tests including security edge cases - Add early exit optimization for performance This prevents identical errors from being split into multiple groups due to differences in user environments, making error monitoring more effective. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
…ping This change implements much more aggressive stack trace normalization to ensure identical errors always produce identical stack traces, regardless of environment. Key changes: - Strip ALL absolute path prefixes (no more <HOME>, <CI_WORKSPACE>, etc) - For node_modules: extract ONLY the part after node_modules/ - For other paths: remove all leading slashes to make them relative - Preserve original stack trace in Bugsnag metadata for debugging Examples of normalization: - /Users/john/project/node_modules/@shopify/cli/dist/index.js → @shopify/cli/dist/index.js - /home/user/.yarn/cache/@shopify-cli-npm-3.45.0/node_modules/@shopify/cli/dist/index.js → @shopify/cli/dist/index.js - /github/workspace/packages/cli-kit/src/error.js → packages/cli-kit/src/error.js This ensures identical errors produce identical stack traces regardless of: - Installation location (global vs local) - Package manager (npm/yarn/pnpm) - Operating system (Windows/Mac/Linux) - User home directory - CI/CD environment The original stack trace is preserved in Bugsnag metadata under "original_stacktrace" for debugging purposes. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
We detected some changes at Caution DO NOT create changesets for features which you do not wish to be included in the public changelog of the next CLI release. |
Coverage report
Show files with reduced coverage 🔻
Test suite run success3073 tests passing in 1315 suites. Report generated by 🧪jest coverage report action from fdfd987 |
['macOS home', '/Users/john/project/file.js', 'Users/john/project/file.js'], | ||
['Linux home', '/home/jane/work/app.js', 'home/jane/work/app.js'], |
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.
Shouldn't user names be removed here?
[ | ||
'Windows AppData Roaming', | ||
'/Users/LENOVO/AppData/Roaming/npm/node_modules/@shopify/cli/dist/chunk-AE3MLJMV.js', | ||
'@shopify/cli/dist/chunk-<HASH>.js', | ||
], | ||
['Windows AppData Local', '/Users/john/AppData/Local/Programs/app.js', 'Users/john/AppData/Local/Programs/app.js'], | ||
['Windows AppData Temp', '/Users/john/AppData/Local/Temp/test.js', 'Users/john/AppData/Local/Temp/test.js'], |
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.
Same here for Windows AppData Local and Temp
Sorry @isaacroldan, this is still WIP. I've converted to draft. |
- Strip ALL environment-specific path prefixes to improve error grouping - Remove user home directories, temp paths, CI workspaces entirely - Handle yarn/pnpm cache paths by extracting only the package-relative path - Aggressively strip Windows AppData paths (Local/Programs, Roaming, etc.) - Preserve original stack traces in Bugsnag metadata for debugging - Fix linter errors by moving inline comments to separate lines This ensures identical errors produce identical stack traces regardless of: - Installation method (npm, yarn, pnpm, global vs local) - User home directory location - Operating system (Windows/Mac/Linux) - CI/CD environment (GitHub Actions, GitLab, etc.) - Container or temporary directory paths 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Summary
This PR implements aggressive stack trace normalization to ensure identical errors always produce identical stack traces, regardless of environment differences. This will significantly improve error grouping in our telemetry system.
Problem
Previously, the same error would create different stack traces depending on:
This caused identical errors to be split into multiple groups in Bugsnag, making it difficult to identify and prioritize issues.
Solution
Aggressive path normalization: Strip ALL absolute path prefixes
node_modules
paths: Extract only the part afternode_modules/
Preserve original stack traces: Store the original stack trace in Bugsnag metadata under
original_stacktrace
for debuggingExamples
All of these paths now normalize to the same result:
Testing
Notes
fileShort
property, but it adds relative path prefixes that make the problem worse🤖 Generated with Claude Code