Bug fixing with Forge combines human debugging intuition with AI agent execution power. You identify and reproduce the bug, AI agents help fix it, and you verify the solution actually works.
Title: "API returns 500 on malformed JSON input"Description: Environment: Production API v2.3.1 Endpoint: POST /api/users Steps to Reproduce: 1. Send POST request with malformed JSON 2. Missing closing brace in request body Expected: 400 Bad Request with error message Actual: 500 Internal Server Error Impact: High - crashes API server Frequency: ~50 requests/day Example Request: { "name": "John Doe", "email": "john@example.com" # Missing closing braceLabels: bug, backend, priority:high, security
forge task create \ --title "API returns 500 on malformed JSON input" \ --type bug \ --priority high \ --labels "backend,security" \ --description "$(cat <<EOFEnvironment: Production API v2.3.1Endpoint: POST /api/usersSteps to Reproduce:1. Send POST request with malformed JSON2. Missing closing brace crashes serverExpected: 400 Bad RequestActual: 500 Internal Server ErrorImpact: High - crashes API serverEOF)"
"I found a bug in production. Create a bug task:Title: API returns 500 on malformed JSON inputType: bugPriority: highLabels: backend, securityThe POST /api/users endpoint crashes with 500 when receiving malformed JSON.It should return 400 Bad Request instead.This happens about 50 times per day and crashes the API server.High priority security issue."
# Create a task specifically for reproductionforge task create \ --title "Reproduce: API 500 on malformed JSON" \ --description "Write failing test that demonstrates the bug" \ --labels "bug,reproduction" \ --agent claude-code
# Run all three approachesforge task start task-1 --agent claude-codeforge task fork task-1 --agent geminiforge task fork task-1 --agent cursor-cli# Compare resultsforge task compare task-1# Test each approachforge task test task-1-attempt-1forge task test task-1-attempt-2forge task test task-1-attempt-3
# Run the original failing testforge task test task-reproduction# Should now pass ✅
2. Edge Cases Covered
# Create additional test taskforge task create \ --title "Test edge cases for JSON parsing fix" \ --description "Test various malformed JSON scenarios" \ --agent claude-code
Tests should cover:
Missing closing bracket
Extra commas
Invalid escape sequences
Empty request body
Non-JSON content type
3. No Regressions
# Run full test suiteforge task create \ --title "Run full test suite" \ --agent cursor-cli
Ensure the fix didn’t break existing functionality.
4. Performance Impact
# Benchmark before and afterforge task create \ --title "Benchmark JSON parsing performance" \ --description "Compare performance before and after fix" \ --agent gemini
# Create comprehensive test taskforge task create \ --title "Add regression test suite for JSON parsing" \ --description "Cover all malformed JSON scenarios found in production" \ --agent claude-code \ --labels "testing,regression"
Update documentation to help prevent similar bugs.
Code Comments
CHANGELOG
API Documentation
// ⚠️ IMPORTANT: JSON parsing error handler// This middleware catches SyntaxError from malformed JSON// and returns 400 instead of crashing with 500.// See: https://github.com/yourorg/repo/issues/123app.use((err, req, res, next) => { if (err instanceof SyntaxError && 'body' in err) { return res.status(400).json({ error: 'Invalid JSON', message: 'Request body contains malformed JSON' }); } next();});
## [2.3.2] - 2024-10-31### Fixed- API now returns 400 Bad Request instead of 500 when receiving malformed JSON- Added comprehensive error messages for JSON parsing errors- Added regression test suite for JSON validation### Security- Fixed crash vulnerability when processing malformed JSON input
Characteristics: Production down, data loss, security breachStrategy:
# Use fastest, most reliable agentforge task create --title "URGENT: Fix auth bypass" --agent claude-code# No time for multiple attempts - go with proven agent# Document and refactor later if needed
Characteristics: Feature broken, bad UX, performance issueStrategy:
# ✅ Correct order1. Write failing test2. Run test (confirms it fails)3. Fix the bug4. Run test (confirms it passes)# ❌ Wrong order1. Make changes hoping to fix bug2. Deploy and pray
Remember: Bugs are opportunities to improve. With Forge, you can experiment with multiple fix approaches in isolation, choose the best solution, and ensure it never happens again.