← Back to Demo Hub
Test #4Basic Errors

JSON Parse Error

Attempting to parse an invalid JSON string - often happens when server returns HTML error pages.

📋 Demo Instructions

  1. Click the "Trigger Error" button below
  2. Open browser console (F12) to see the error
  3. Wait 5-10 seconds for the error to be captured
  4. Go to Dashboard → Performance Monitoring
  5. Click "Fix with Carla" on the error
  6. Review the generated PR
🌍 Real-World Scenario
API returns an HTML error page (like a 500 error or nginx gateway timeout) instead of JSON. This commonly happens when there are server issues, authentication problems, or network proxies inject error pages.
✅ Expected Fix
Wrap JSON.parse in a try-catch block to gracefully handle parse failures. Also consider validating the response content-type header before parsing.
Fix Confidence:MEDIUM

💻 Buggy Code

// Buggy Code
const response = '<html><body>Error 500</body></html>';
const data = JSON.parse(response);
// SyntaxError: Unexpected token '<', "<html><bod"... is not valid JSON

🔴 Error Log

Waiting for error to be triggered...