Error Handling
Scribe Backend uses standard HTTP status codes and provides detailed error messages to help you troubleshoot issues.Error Response Format
All errors follow a consistent JSON structure:Simple Error
Validation Error (422)
Pydantic validation errors include field-level details:Task Failure Error
Celery task failures include execution context:HTTP Status Codes
2xx Success
| Code | Name | Description |
|---|---|---|
| 200 | OK | Request succeeded |
| 201 | Created | Resource created successfully |
| 202 | Accepted | Async task accepted for processing |
4xx Client Errors
| Code | Name | Description | Common Causes |
|---|---|---|---|
| 400 | Bad Request | Invalid request parameters | Invalid UUID format, out-of-range values |
| 401 | Unauthorized | Missing or invalid authentication | Missing Bearer token, expired JWT, invalid token |
| 403 | Forbidden | Authenticated but insufficient permissions | User not initialized, accessing another user’s resource |
| 404 | Not Found | Resource not found | Invalid email_id, deleted queue item |
| 422 | Unprocessable Entity | Validation error | Missing required fields, invalid data types |
| 429 | Too Many Requests | Rate limit exceeded | Submitting > 100 queue items |
5xx Server Errors
| Code | Name | Description | Action |
|---|---|---|---|
| 500 | Internal Server Error | Unexpected server error | Contact support with task_id |
| 503 | Service Unavailable | Service temporarily unavailable | Retry after delay, check /health endpoint |
Common Error Scenarios
401 Unauthorized
Missing Authorization Header
Missing Authorization Header
Invalid or Expired Token
Invalid or Expired Token
Error:Solution:
- Refresh your token using Supabase
refreshSession() - If refresh fails, re-authenticate with Supabase
- Obtain a new JWT token
403 Forbidden
User Not Initialized
User Not Initialized
Error:Solution:
404 Not Found
Email Not Found
Email Not Found
Error:Possible Causes:
- Invalid UUID format
- Email belongs to another user
- Email was deleted
422 Validation Error
Missing Required Fields
Missing Required Fields
Error:Solution:
Ensure all required fields are included:
Field Length Constraints
Field Length Constraints
Error:Constraints:
email_template: 10-5000 charactersrecipient_name: 2-255 charactersrecipient_interest: 2-500 characters
429 Rate Limit
Batch Size Exceeded
Batch Size Exceeded
Error:Solution:
Split your batch into multiple requests with ≤100 items each.
500 Internal Server Error
Unexpected Server Error
Unexpected Server Error
Error:Action:
- Check the
/healthendpoint to verify service status - Retry the request after a short delay
- If the issue persists, contact support with the
task_idor request details
503 Service Unavailable
Database Connection Failed
Database Connection Failed
Error:Action:
- Check
/healthendpoint for database status - Wait 30 seconds and retry
- If persistent, the service may be under maintenance
Task Execution Errors
When using async endpoints likePOST /api/email/generate, task failures are reported via the status endpoint:
Pipeline Step Failures
| Step | Error Type | Common Cause |
|---|---|---|
template_parser | ValidationError | Invalid template format |
web_scraper | ExternalAPIError | Google API quota, network timeout |
arxiv_helper | ExternalAPIError | ArXiv API unavailable |
email_composer | ValidationError | LLM output parsing failed |
Retrying Failed Tasks
Tasks with transient errors (API timeouts, rate limits) are automatically retried:- Max retries: 3
- Retry delay: 30 seconds
- Backoff: Exponential (30s, 60s, 120s)
After 3 failed retries, the task enters
FAILURE state permanently. You must submit a new request to retry.Error Recovery Strategies
Automatic Retry with Exponential Backoff
Handling Validation Errors
Debugging Tips
Check /health endpoint
Verify service availability and database connectivity
Inspect task status
Use
GET /api/email/status/{task_id} for detailed error infoReview Logfire traces
Access distributed traces with task_id for root cause analysis
Test in /docs
Use FastAPI’s interactive docs to isolate issues
Support
If you encounter persistent errors:-
Collect the following information:
- HTTP status code
- Error message
- Request payload
task_id(if applicable)- Timestamp
-
Check the
/healthendpoint for service status - Review Common Error Scenarios above
- Contact support with the collected information
Authentication Guide
Troubleshoot authentication errors
Task Status
Monitor async task execution
