Overview
Reports in Reportr go through multiple processing states from creation to completion. The status field provides real-time visibility into the report generation pipeline, allowing you to track progress, handle errors, and provide user feedback.Report Status Enum
TheReportStatus enum is defined in the Prisma schema and has four possible values:
Status Definitions
PENDING
Description: Report has been created and queued for processing but generation has not started. Characteristics:processingStartedAtisnullprocessingCompletedAtisnullpdfUrlisnulldatafield contains the input configuration
PROCESSING
Use Case: This status exists for future queue-based processing implementation. Currently, reports move immediately to PROCESSING.
PROCESSING
Description: Report generation is actively in progress. The system is fetching data, generating AI insights, and creating the PDF. Characteristics:processingStartedAthas a timestampprocessingCompletedAtisnullpdfUrlisnull- AI insights are being generated
- PDF is being rendered with React-PDF
- User authentication and authorization (1s)
- Plan limit verification (1s)
- Client ownership validation (1s)
- AI insights generation with Claude API (3-8s)
- PDF rendering with React-PDF (5-15s)
- Upload to Vercel Blob storage (1-3s)
- Database record update (1s)
COMPLETED (success) or FAILED (error)
Timeout: 60 seconds (serverless function maximum duration)
COMPLETED
Description: Report generation finished successfully. The PDF is available for download. Characteristics:processingStartedAthas a timestampprocessingCompletedAthas a timestamppdfUrlcontains the Vercel Blob storage URLpdfSizecontains file size in bytesgenerationTimeMscontains total processing timeerrorMessageisnull- AI insights may be present (depending on AI service availability)
- Complete analytics data in
datafield - AI-generated insights in
aiInsightsarray - PDF download URL in
pdfUrl - Performance metrics (
generationTimeMs,aiTokensUsed,aiCostUsd)
FAILED
Description: Report generation encountered an unrecoverable error and could not complete. Characteristics:processingStartedAtmay have a timestamp (if processing began)processingCompletedAtisnullpdfUrlisnullerrorMessagecontains error detailsgenerationTimeMsmay be present (time until failure)
- Validation errors: Invalid input data structure
- Authentication errors: Session expired during processing
- API failures: Google API or Claude API unavailable
- PDF rendering errors: React-PDF timeout or memory issues
- Storage errors: Vercel Blob upload failed
- Database errors: Prisma connection or query failures
- Timeout: Processing exceeded 60 second limit
Status Transitions
Valid Transitions:null→PENDING(report created)PENDING→PROCESSING(generation started)PROCESSING→COMPLETED(success)PROCESSING→FAILED(error)
- Cannot go from
COMPLETEDorFAILEDto any other state - Cannot skip states (e.g.,
PENDING→COMPLETED)
Checking Report Status
Use the Retrieve Report endpoint to check the current status:status field:
Polling for Completion
For asynchronous report generation (future implementation), implement polling:Status in List Reports
The List Reports endpoint includes status for filtering:Database Schema
The status field is defined in the Report model:@@index([status]) directive creates a database index for efficient status-based queries.
Monitoring and Analytics
Success Rate
Calculate report generation success rate:Average Generation Time
Track performance by status:Error Analysis
Identify common failure patterns:Best Practices
For Frontend Developers
- Show status to users: Display clear status indicators (loading spinner for PROCESSING, success checkmark for COMPLETED, error icon for FAILED)
- Handle all states: Account for all four status values in your UI logic
-
Display error messages: Show
errorMessageto users when status is FAILED - Implement retry: Allow users to regenerate failed reports with corrected parameters
- Cache completed reports: Don’t re-fetch completed reports unnecessarily
For Backend Developers
- Set status immediately: Update status to PROCESSING as soon as generation starts
- Always set final status: Ensure PROCESSING reports transition to COMPLETED or FAILED
- Detailed error messages: Provide actionable error messages for debugging
- Log status transitions: Log all status changes for monitoring and debugging
- Handle timeouts gracefully: Set status to FAILED if processing exceeds time limits
For API Consumers
- Check status before downloading: Verify status is COMPLETED before accessing pdfUrl
- Handle asynchronous generation: Implement polling or webhooks for async workflows
- Parse error messages: Extract useful information from errorMessage for user display
- Track generation metrics: Monitor generationTimeMs for performance optimization
Future Enhancements
Planned Status Features
- Webhooks: Notify external systems when status changes to COMPLETED or FAILED
- Progress percentage: Add sub-states to PROCESSING (e.g., “Fetching data”, “Generating insights”, “Creating PDF”)
- Retry mechanism: Automatic retry for transient failures (API timeouts, rate limits)
- Queue position: Show position in queue for PENDING reports
- Estimated completion: Predict completion time based on historical data
Related Endpoints
- Generate Report - Create a new report (sets initial status)
- List Reports - Get all reports with status filtering
- Retrieve Report - Get detailed status information