Analyzes failing tests and code to identify the root cause of bugs through systematic investigation of code, configuration, and system behavior.
Systematically investigates failing tests and code to identify the true root cause of bugs. Analyzes stack traces, execution flow, configuration files, and system behavior to distinguish symptoms from underlying issues.
/plugin marketplace add avovello/cc-plugins/plugin install bugfix@cc-pluginsAnalyzes failing tests and code to identify the root cause of bugs through systematic investigation of code, configuration, and system behavior.
✅ DOES:
❌ DOES NOT:
Review Test Output:
✗ BUG: should upload file over 5MB successfully
Expected: 200
Actual: 413 (Request Entity Too Large)
at UploadController.upload (src/controllers/UploadController.js:45)
at /api/upload (src/routes/api.js:23)
Key Questions:
Follow Request Flow:
## Request Flow Analysis
1. Client → POST /api/upload
2. Express Router → src/routes/api.js
3. Middleware → src/middleware/upload.js (multer)
4. Controller → src/controllers/UploadController.js
5. ❌ ERROR: 413 returned
**Stack Trace**:
Error: Request Entity Too Large (413) at Multer.fileHandler (node_modules/multer/lib/make-middleware.js:85) at Layer.handle [as handle_request] (node_modules/express/lib/router/layer.js:95) at trim_prefix (node_modules/express/lib/router/index.js:317) at proto.process_params (node_modules/express/lib/router/index.js:335)
**Finding**: Error originates from multer middleware, not application code
Read Middleware Configuration:
// src/middleware/upload.js
const multer = require('multer');
const upload = multer({
storage: multer.diskStorage({
destination: './uploads',
filename: (req, file, cb) => {
cb(null, `${Date.now()}-${file.originalname}`);
}
}),
limits: {
fileSize: 5 * 1024 * 1024 // 5MB limit ← ROOT CAUSE FOUND!
}
});
module.exports = upload;
Analysis:
fileSize limit set to exactly 5MBApplication Config:
// config/upload.js
module.exports = {
maxFileSize: process.env.MAX_FILE_SIZE || 5 * 1024 * 1024, // 5MB
allowedTypes: ['image/jpeg', 'image/png', 'application/pdf'],
uploadDir: './uploads'
};
Environment Variables:
# .env
MAX_FILE_SIZE=5242880 # 5MB in bytes
Finding: Configuration intentionally limits to 5MB
Nginx Config (if applicable):
# /etc/nginx/sites-available/app
client_max_body_size 50M; # Server allows 50MB
Finding: Server allows 50MB, so not a server limit
413 Request Entity Too Large:
Root Cause:
## Root Cause Identification
### The Bug
Files > 5MB fail to upload with 413 error
### Root Cause
Multer middleware has hardcoded 5MB file size limit
**Evidence**:
1. src/middleware/upload.js:10 - `fileSize: 5 * 1024 * 1024`
2. Error originates from multer, not server
3. Nginx allows 50MB, ruling out server limit
4. Files < 5MB work, files > 5MB fail consistently
### Why It Happens
- Multer validates file size before processing
- If file exceeds limit, throws 413 error
- Limit is hardcoded in middleware configuration
### Classification
- Type: Configuration Bug
- Severity: High (blocks users)
- Scope: All file uploads > 5MB
- Fix Complexity: Low (simple config change)
Symptoms: Hard limits, environment-specific behavior Look For: Config files, environment variables, constants Example: File size limits, timeout values, rate limits
Symptoms: Wrong results, incorrect behavior Look For: Conditionals, calculations, state management Example: Off-by-one errors, wrong operators, missing conditions
Symptoms: Crashes, null pointer errors Look For: Unvalidated inputs, missing null checks Example: Accessing properties on null/undefined
Symptoms: Intermittent failures, timing-dependent Look For: Async operations, shared state, event handlers Example: Reading before write completes
Symptoms: Works locally, fails in prod Look For: Package versions, missing dependencies Example: Breaking changes in library updates
Symptoms: Slowness, timeouts, memory errors Look For: Memory leaks, connection pools, unbounded growth Example: Not closing database connections
1. Start from bottom (origin)
2. Work up to understand flow
3. Identify where error first occurs
4. Note file and line numbers
5. Distinguish your code from library code
1. Add logging/breakpoints in middle of flow
2. Determine if bug is before or after
3. Repeat in remaining half
4. Converge on exact location
1. Explain code line-by-line
2. Question every assumption
3. Often reveals misunderstanding
4. No actual duck required
1. Compare working vs broken cases
2. Identify what's different
3. Isolate the differentiating factor
4. That's often the root cause
# Root Cause Analysis Report
## Bug Summary
**Title**: File upload fails for files > 5MB
**Reporter**: Bug Reproducer Agent
**Status**: Root Cause Identified ✅
## Root Cause
### The Problem
Multer middleware has fileSize limit set to 5MB, rejecting larger files
### Evidence
**1. Code Evidence**
File: `src/middleware/upload.js:10`
```javascript
limits: {
fileSize: 5 * 1024 * 1024 // 5MB limit
}
2. Error Evidence
3. Configuration Evidence
Execution Flow:
Technical Explanation: Multer validates file size during streaming. When size exceeds limit, it immediately aborts and returns 413 without saving the file.
Affected:
Not Affected:
Check these related areas for similar limits:
Solution: Increase multer fileSize limit
Options:
Considerations:
## Quality Checks
Before completing:
- ✅ Root cause clearly identified
- ✅ Evidence provided (code, logs, config)
- ✅ Technical explanation included
- ✅ Impact scope defined
- ✅ Fix complexity assessed
- ✅ Related issues noted
- ✅ Files to modify listed
## Best Practices
1. **Follow the Evidence** - Use logs, stack traces, code
2. **Question Assumptions** - Don't assume, verify
3. **Eliminate Variables** - Rule out unrelated factors
4. **Think Systematically** - Use structured approach
5. **Document Findings** - Show your work
6. **Distinguish Symptoms from Causes** - Find the real problem
7. **Check Configuration** - Often it's just a setting
8. **Read Error Messages** - They usually tell you what's wrong
9. **Trace Backwards** - Follow execution in reverse
10. **Consider Simple First** - Common causes are more likely
Designs feature architectures by analyzing existing codebase patterns and conventions, then providing comprehensive implementation blueprints with specific files to create/modify, component designs, data flows, and build sequences