This project is a full-stack application (React + Flask) deliberately riddled with 16 sophisticated software bugs. It's designed to test an experienced senior engineer's debugging skills across frontend, backend, and infrastructure (Docker). These are production-like bugs that require deep understanding of React, Python, databases, and containerization.
Target Audience: Senior Software Engineers (3+ years experience)
Estimated Time: 45 minutes (5 min setup, 35 min debugging, 5 min discussion)
Difficulty Level: Advanced - requires expertise in React hooks, state management, async operations, database optimization, Docker, and performance debugging.
- Race Condition (Bug #1): Global state mutations without proper synchronization causing data corruption in concurrent requests
- Memory Exhaustion (Bug #2): Unbounded cache growth leading to resource exhaustion attacks
- Complex Mathematical Error (Bug #3): Sophisticated weighted average calculations with exponential weight progression flaw
- Authentication Bypass (Bug #4): Multi-stage logic flaw allowing privilege escalation through OR conditions
- Resource Management (Bug #5): Multiple database connection leaks in success and error paths
- Circular Reference (Bug #6): JSON serialization failures due to self-referential objects in API responses
- Context Performance (Bug #7): Unnecessary re-renders caused by context value recreation on every render
- Infinite Re-render Loop (Bug #8): useEffect dependencies causing endless render cycles due to object recreation
- Stale Closure (Bug #9): Async operations capturing outdated state values due to missing dependencies
- Memory Leak (Bug #10): Uncleaned intervals causing memory accumulation and performance degradation
- State Mutation (Bug #11): Direct modifications of state objects breaking React's reconciliation algorithm
- Key Prop Issues (Bug #12): Using array indices as keys causing list rendering corruption and state issues
- Performance Bottleneck (Bug #13): Expensive synchronous operations blocking main thread - requires React Profiler to identify
- Environment Variable Precedence (Bug #14): Conflicting environment variables overriding each other in unexpected ways
- Volume Permission Issues (Bug #15): Incorrect read-only volume mounts preventing hot reloading and development workflows
- Health Check Misconfiguration (Bug #16): Wrong endpoints and conditions causing delayed service availability
- Weather Dashboard: Complex mathematical calculations with exponential weight progression errors
- User Management: State management with mutation issues and performance problems
- Session Authentication: Multi-stage authentication with bypass vulnerabilities
- Database Statistics: Resource management and connection pooling problems
- React Context: Performance optimization and re-render issues
- Component Lifecycle: Memory leaks and cleanup problems
- Docker Environment: Configuration conflicts and permission issues
- Docker and Docker Compose installed
- A code editor with debugging capabilities (VS Code recommended)
- Browser with developer tools (Chrome DevTools recommended)
- Understanding of React DevTools and profiling
-
Clone the repository:
git clone <repository-url> cd debugging-interview
-
Build and Run with Docker Compose:
docker-compose up --build
This command will:
- Build Docker images for frontend, backend, and nginx
- Start containers with intentional configuration issues
- Initialize SQLite database with ~500 test users
- The frontend (React) will be served on
http://localhost:3000 - The backend (Flask) will be accessible via
http://localhost:5000 - Nginx will proxy the application on
http://localhost:80
-
Access the Application: Open your browser and navigate to
http://localhost(orhttp://localhost:80)- The React frontend should load with advanced debugging features
- Backend API calls include weather data, user management, and statistics
- Try all UI interactions including "Fetch DB Stats", user selection, weather requests, and authentication
- Explore the Application: Test all features - login, weather dashboard, user list, database stats
- Identify Bug Categories: Recognize performance, memory, logic, security, and infrastructure issues
- Use Developer Tools: Browser DevTools, React DevTools, Network tab, Performance profiler
-
Backend Investigation:
- Analyze API response times and mathematical calculation errors
- Check server logs for race conditions and resource leaks
- Test authentication flows and bypass vulnerabilities
- Examine database connection management
-
Frontend Analysis:
- Profile React component re-renders and memory usage
- Test user interactions for state corruption and infinite loops
- Analyze async operation handling and closure issues
- Check for memory leaks and performance degradation
-
Infrastructure Review:
- Examine Docker container health and environment conflicts
- Check volume mounts and permission issues
- Analyze service dependencies and startup behavior
- Prioritize Fixes: Which bugs would you fix first in production?
- Explain Root Causes: Demonstrate understanding of underlying issues
- Propose Prevention: How would you prevent these bug categories?
Senior Level Expectations:
- Identify 80%+ of bugs (13+ out of 16)
- Explain root causes with technical depth
- Propose systematic solutions not just quick fixes
- Demonstrate profiling skills using advanced debugging tools (especially for Bug #13)
- Understand production implications of each bug category
- Suggest prevention strategies (testing, monitoring, code review)
- Chrome DevTools: Performance tab, Memory tab, Network analysis
- React DevTools: Profiler, Component tree, Hook inspection
- Docker Tools: Container stats, log analysis, health monitoring
- Code Analysis: Understanding async patterns, state management, memory management
| Category | Count | Examples |
|---|---|---|
| Concurrency | 2 | Race conditions, authentication bypass |
| Memory/Performance | 5 | Cache leaks, infinite loops, expensive operations, main thread blocking |
| State Management | 3 | React mutations, stale closures, context issues |
| Infrastructure | 3 | Docker configs, volume permissions, health checks |
| Security | 1 | Authentication bypass vulnerabilities |
| Data Processing | 2 | Mathematical errors, circular references |
- Race Conditions: Multiple rapid weather API calls show inconsistent request counters
- Memory Growth: Weather cache grows indefinitely - check memory usage over time
- Math Errors: Weather calculations seem wrong - compare weighted vs simple averages
- Auth Bypass: Try password "admin" or login with user ID < 10 (check database)
- Resource Leaks: Database connections not properly closed - check
/api/db-stats - JSON Errors:
/api/db-statsendpoint fails with circular reference serialization
- Context Re-renders: React DevTools shows unnecessary component updates
- Infinite Loops: Browser becomes unresponsive, check console for render warnings
- Stale Data: User info in delayed notifications shows wrong/old username
- Memory Leaks: Check browser memory tab - notifications interval never stops
- State Mutations: User preference changes don't trigger re-renders
- List Corruption: User selection state gets mixed up when paginating
- Performance: Typing in weather input freezes UI - use React Profiler
- Environment Conflicts: Backend logs show conflicting DEBUG values
- Volume Permissions: Hot reloading doesn't work - files are read-only
- Health Checks:
docker psshows backend as "unhealthy" status
- Focus on systematic debugging rather than random testing
- Use profiling tools to identify performance bottlenecks (essential for Bug #13)
- Look for patterns across similar bugs (e.g., all state mutations)
- Test edge cases and concurrent operations
- Pay attention to console logs and error messages
- Consider production impact of each bug type
- Try typing in the weather input field - severe performance issues require React Profiler to diagnose
Good luck! This challenge reflects real-world debugging scenarios that senior engineers face in production systems.
- Hot Reloading: Frontend should support live code changes (but has volume permission issues)
- Database Reset:
docker-compose down && docker-compose up --buildresets everything - Logs:
docker-compose logs -f <service_name>for detailed debugging - Container Stats:
docker statsto monitor resource usage during debugging
-
Lines 15-16:
user_sessions = {}; session_counter = 0- Race condition without locks- Test: Make multiple rapid weather API calls, observe inconsistent request counters
- Symptom: Counter values don't increment correctly under load
-
Line 19:
weather_cache = {}- Unbounded cache causing memory exhaustion- Test: Make weather requests for different cities over time
- Symptom: Memory usage grows continuously, cache never clears
-
Line 42:
weights = [2 ** i for i in range(len(temps))]- Exponential weight error- Test: Compare weather calculations - later readings have exponentially more weight
- Symptom: Temperature averages skewed toward last few readings
-
Lines 58-65: Authentication bypass logic in
verify_session()decorator- Test: Try password "admin" or login with any user ID < 10
- Symptom: Authentication succeeds without proper credentials
-
Lines 281-282: Multiple database connections opened, only one closed
- Test: Call
/api/db-statsmultiple times, monitor database connections - Symptom: Database connection pool exhaustion over time
- Test: Call
-
Line 302:
stats['self_reference'] = stats- Circular reference in JSON- Test: Call
/api/db-statsendpoint - Symptom: JSON serialization error, endpoint returns 500
- Test: Call
-
Lines 8-22 (App.js): Context value recreated on every render in
AppProvider- Test: Use React DevTools Profiler, observe unnecessary re-renders
- Symptom: All context consumers re-render on every state change
-
Lines 47-50 (App.js): useEffect with
userPreferencesdependency causing infinite loop- Test: Open browser console, observe continuous re-render warnings
- Symptom: Browser becomes unresponsive, infinite console logs
-
Lines 53-62 (App.js):
fetchDelayedDatawith empty dependency array missinguser- Test: Login, wait 2 seconds for delayed notification
- Symptom: Notification shows wrong/undefined username
-
Lines 65-72 (App.js): Interval created without cleanup function
- Test: Use browser Memory tab, observe growing memory usage
- Symptom: Memory leak, interval continues after component unmount
-
Line 112 (App.js): Direct state mutation:
userPreferences[key] = value- Test: Try toggling theme or changing preferences
- Symptom: UI doesn't update when preferences change
-
Line 73 (UserList.js): Using array index as key:
key={index}in UserList- Test: Select users, then paginate or search
- Symptom: Selection state gets corrupted, wrong users appear selected
-
Lines 9-25 (WeatherDashboard.js): Expensive computation on every render - requires React Profiler
- Test: Type in weather city input field
- Symptom: UI freezes while typing, main thread blocked
-
Lines 10-13:
DEBUG=truethenDEBUG=false- conflicting env vars- Test: Check backend container logs for environment variable conflicts
- Symptom: Inconsistent debug behavior, conflicting log levels
-
Line 26:
:roread-only volume mount preventing hot reload- Test: Try modifying frontend files, check if changes auto-reload
- Symptom: Hot reloading doesn't work, files are read-only in container
-
Line 17: Health check uses wrong endpoint
/api/nonexistent- Test: Run
docker psand check container health status - Symptom: Backend container shows as "unhealthy" despite working properly
- Test: Run
# Check container health
docker ps
# Monitor memory usage
docker stats
# Check backend logs
docker-compose logs backend
# Test endpoints manually
curl http://localhost:5000/api/health # Should work
curl http://localhost:5000/api/nonexistent # Should fail (404)
# Test authentication bypass
curl -X POST http://localhost:5000/api/login \
-H "Content-Type: application/json" \
-d '{"username":"user1","password":"admin"}'