From ec93004502a3be1d54cc1dc5ed6d466bb8fb6737 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 5 Nov 2025 14:19:28 +0000 Subject: [PATCH] Fix orchestration saga failure due to schema mismatch and missing pandas Root Causes Fixed: 1. BatchForecastResponse schema mismatch in forecasting service - Changed 'batch_id' to 'id' (required field name) - Changed 'products_processed' to 'total_products' - Changed 'success' to 'status' with "completed" value - Changed 'message' to 'error_message' - Added all required fields: batch_name, completed_products, failed_products, requested_at, completed_at, processing_time_ms, forecasts - This was causing "11 validation errors for BatchForecastResponse" which made the forecast service return None, triggering saga failure 2. Missing pandas dependency in orchestrator service - Added pandas==2.2.2 and numpy==1.26.4 to requirements.txt - Fixes "No module named 'pandas'" warning when loading AI enhancement These issues prevented the orchestrator from completing Step 3 (generate_forecasts) in the daily workflow, causing the entire saga to fail and compensate. --- .../app/api/forecasting_operations.py | 17 ++++++++++++----- services/orchestrator/requirements.txt | 4 ++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/services/forecasting/app/api/forecasting_operations.py b/services/forecasting/app/api/forecasting_operations.py index 67b560ba..16199d8c 100644 --- a/services/forecasting/app/api/forecasting_operations.py +++ b/services/forecasting/app/api/forecasting_operations.py @@ -242,13 +242,20 @@ async def generate_batch_forecast( if not inventory_product_ids: logger.info("No products found for forecasting", tenant_id=tenant_id) from app.schemas.forecasts import BatchForecastResponse + now = datetime.now(timezone.utc) return BatchForecastResponse( - batch_id=str(uuid.uuid4()), + id=str(uuid.uuid4()), tenant_id=tenant_id, - products_processed=0, - forecasts_generated=0, - success=True, - message="No products found for forecasting" + batch_name=getattr(request, 'batch_name', f"orchestrator-batch-{datetime.now().strftime('%Y%m%d')}"), + status="completed", + total_products=0, + completed_products=0, + failed_products=0, + requested_at=now, + completed_at=now, + processing_time_ms=0, + forecasts=None, + error_message=None ) # Skip rate limiting for service-to-service calls (orchestrator) diff --git a/services/orchestrator/requirements.txt b/services/orchestrator/requirements.txt index a8caafe0..e6fe2e78 100644 --- a/services/orchestrator/requirements.txt +++ b/services/orchestrator/requirements.txt @@ -14,6 +14,10 @@ psycopg2-binary==2.9.10 # HTTP clients (for service orchestration) httpx==0.28.1 +# Data processing and ML support +pandas==2.2.2 +numpy==1.26.4 + # Redis for leader election redis==6.4.0