Diagnose errors, exceptions, and stack traces. Find root cause and suggest fixes.
Diagnoses errors, analyzes stack traces, identifies root causes, and suggests fixes.
/plugin marketplace add adelabdelgawad/fullstack-agents/plugin install adelabdelgawad-fullstack-agents-plugins-fullstack-agents@adelabdelgawad/fullstack-agentsDiagnose errors, analyze stack traces, identify root causes, and suggest fixes.
/debug errorPython errors:
- ImportError / ModuleNotFoundError → Missing dependency
- AttributeError → Wrong attribute/method name
- TypeError → Wrong type passed
- ValueError → Invalid value
- KeyError → Missing dictionary key
- IndexError → List index out of range
- ConnectionError → Database/API connection issue
- TimeoutError → Operation timeout
- SQLAlchemyError → Database query error
- ValidationError → Pydantic validation failed
JavaScript/TypeScript errors:
- TypeError → Undefined/null access
- ReferenceError → Undefined variable
- SyntaxError → Code syntax issue
- NetworkError → API call failed
- Hydration error → SSR/Client mismatch
- Module not found → Import path wrong
Extract key information:
# Key fields to extract
error_info = {
"type": "ValueError",
"message": "Invalid value for field 'email'",
"file": "api/services/user_service.py",
"line": 45,
"function": "create_user",
"call_stack": [
{"file": "api/v1/users.py", "line": 23, "function": "create_user_endpoint"},
{"file": "api/services/user_service.py", "line": 45, "function": "create_user"},
]
}
Check related code:
# Read the failing file
cat -n {file_path} | head -n {line + 20} | tail -n 40
# Check for related issues
grep -rn "{error_pattern}" --include="*.py"
# Check recent changes
git log --oneline -10 -- {file_path}
git diff HEAD~5 -- {file_path}
## Error Diagnosis Report
### Error Summary
| Field | Value |
|-------|-------|
| Type | `ValueError` |
| Message | Invalid value for field 'email' |
| Location | `api/services/user_service.py:45` |
| Function | `create_user` |
### Stack Trace Analysis
Traceback (most recent call last): File "api/v1/users.py", line 23, in create_user_endpoint result = await user_service.create_user(session, data) File "api/services/user_service.py", line 45, in create_user <-- Error here validated = UserCreate(**data) ValueError: Invalid value for field 'email'
**Call Path:**
1. `api/v1/users.py:23` - Router receives request
2. `api/services/user_service.py:45` - Service validates data ← **Error occurs here**
### Root Cause
**The error occurs because:**
The email field validation is failing. Looking at the code:
```python
# api/services/user_service.py:45
validated = UserCreate(**data) # Pydantic validation fails here
The UserCreate schema expects a valid email format, but the input doesn't match.
Likely causes:
UserCreate schema:
# api/schemas/user_schemas.py
class UserCreate(BaseModel):
email: EmailStr # Requires valid email format
name: str
Input received: Based on the error, the input likely was:
{"email": "invalid", "name": "John"}
Option 1: Fix the input data Ensure the client sends a valid email:
{"email": "john@example.com", "name": "John"}
Option 2: Add better error handling
# api/services/user_service.py
from pydantic import ValidationError
async def create_user(self, session: AsyncSession, data: dict):
try:
validated = UserCreate(**data)
except ValidationError as e:
raise DomainValidationError(f"Invalid user data: {e.errors()}")
Option 3: Make email optional If email should be optional:
# api/schemas/user_schemas.py
class UserCreate(BaseModel):
email: EmailStr | None = None
name: str
To prevent this error in the future:
Add input validation in router:
@router.post("")
async def create_user(
data: UserCreate, # FastAPI validates automatically
session: AsyncSession = Depends(get_session),
):
Add frontend validation:
const schema = z.object({
email: z.string().email("Invalid email"),
name: z.string().min(1),
})
Similar errors might occur in:
api/services/user_service.py:78 - update_user uses same schemaapi/v1/auth.py:34 - register creates userDesigns 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