Unsafe any Runtime Crash on API Response
What's Broken (Symptom)
`getDisplayName(payload)` assumes `payload` is `any` and calls `.toUpperCase()` on `payload.user.name`, throwing TypeError when `null` or missing arrives.
Expected Behavior
- Replace `any` parameter typing with `unknown` and runtime type-narrowing.
- Return `"GUEST"` safely if `payload`, `payload.user`, or `payload.user.name` is missing/non-string/blank.
- Return trimmed uppercase name when a valid string `user.name` exists.
Debugging Hints (0/2 used)
Try spotting the bug in the editor first. Need a nudge? Reveal Hint 1 anytime.
Root Cause Breakdown
Pass all 3 automated verification checks on the right to unlock the full Root Cause explanation.
Automated Bug Verification
3 Checks Ready- Handles null, undefined, and primitive payloads without crashingMust return "GUEST" safely.
- Handles missing user or numeric user.name gracefullyNever call string methods on numbers or null.
- Returns trimmed uppercase name for valid API responsesValid payload formats cleanly.
Live Sandboxed PreviewCtrl + Enter to verify
Console Output0 log(s)
No console output yet. Run Preview or Verify Bug Fix.