Get to the root cause of any code error with a fix, explanation, and prevention strategy.
Help me debug this issue in [Language/Framework]: Error message: ``` [Paste error message] ``` Code causing the error: ```[language] [Paste relevant code] ``` Expected behavior: [What should happen] Actual behavior: [What is happening] Environment: [OS, version, dependencies] Please: 1. Identify the root cause 2. Explain WHY this error occurs 3. Provide the fix with code 4. Explain how the fix resolves it 5. Suggest preventive measures 6. List similar errors to watch for 7. Add defensive code / error handling 8. Unit test to prevent regression