← Back to Demo Hub
Test #3Basic Errors

Array Index Error

Accessing an element of an empty array and trying to read its properties.

📋 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 empty array when no data is found, but the code assumes at least one item exists. Common in product listings, search results, or user data.
✅ Expected Fix
Add array length check before accessing elements, or use optional chaining on the array access.
Fix Confidence:HIGH

💻 Buggy Code

// Buggy Code
const items = [];
console.log(items[0].name);
// TypeError: Cannot read properties of undefined (reading 'name')

🔴 Error Log

Waiting for error to be triggered...