← All Exercises
Group Errors by Fingerprint
intermediatejavascript
Background
Alert fatigue comes from treating every error instance as distinct. Fingerprinting collapses the same defect reported with different ids into one actionable group.
Problem
Normalize volatile parts of error messages (ids, numbers, hex) and group errors into fingerprints with occurrence counts, sorted by frequency.
Input
JSON object: { errors: [{ name, message }] }Output
JSON array of { fingerprint, count } sorted by count desc, then fingerprintSample tests
Sample 1
Input: {"errors":[{"name":"TimeoutError","message":"request 8f3a1b2c timed out after 30s"},{"name":"TimeoutError","message":"request 19ac77de timed out after 30s"},{"name":"TypeError","message":"cannot read property of undefined"}]}Expected: [{"fingerprint":"TimeoutError:request <hex> timed out after <n>s","count":2},{"fingerprint":"TypeError:cannot read property of undefined","count":1}]Sample 2
Input: {"errors":[{"name":"ValidationError","message":"field age must be >= 18"},{"name":"ValidationError","message":"field age must be >= 21"}]}Expected: [{"fingerprint":"ValidationError:field age must be >= <n>","count":2}]Your solution
Learning objective
Collapse duplicate error instances into one group per defect.