Root cause versus symptom
The most tempting trap in debugging is the patch that makes the error disappear without fixing the cause. If user is undefined and you "fix" it with if (user) { ... }, the error stops — but now signups silently do nothing, which is worse: a loud crash at least told you something was wrong, and now nothing does. The real question is why is user undefined here? Maybe the lookup failed. Maybe a field was renamed. Maybe an await is missing upstream.
When the AI proposes a fix, ask it:
- "Is this fixing the cause or hiding the symptom?"
- "What was the original reason the value was wrong?"
- "Could this same root cause break anything else?"
A root-cause fix usually makes the code simpler or clearer. A symptom patch usually adds a guard, a try/catch that swallows errors, or a default value that papers over the real problem. Be suspicious of the second kind. There's a tell worth learning: if a fix adds code whose only job is to prevent a crash rather than to do the right thing, you're probably patching a symptom. Real fixes tend to remove the impossible state entirely, not just survive it.