Fix critical bugs and standardize service integrations
Critical Fixes:
- Orchestrator: Add missing OrchestrationStatus import (fixes HTTP 500 during demo clone)
- Procurement: Migrate from custom cache utils to shared Redis utils
- Suppliers: Use proper Settings for Redis configuration with TLS/auth
- Recipes/Suppliers clients: Fix endpoint paths (remove duplicate path segments)
- Procurement client: Use suppliers service directly for supplier details
Details:
1. services/orchestrator/app/api/internal_demo.py:
- Added OrchestrationStatus import to fix cloning error
- This was causing HTTP 500 errors during demo session cloning
2. services/procurement/app/api/purchase_orders.py + service:
- Replaced app.utils.cache with shared.redis_utils
- Standardizes caching across all services
- Removed custom cache utilities (deleted app/utils/cache.py)
3. services/suppliers/app/consumers/alert_event_consumer.py:
- Use Settings().REDIS_URL instead of os.getenv
- Ensures proper Redis connection with TLS and authentication
4. shared/clients/recipes_client.py:
- Fixed endpoint paths: recipes/recipes/{id} → recipes/{id}
- Applied to all recipe methods (by_id, by_products, instructions, yield)
5. shared/clients/suppliers_client.py:
- Fixed endpoint path: suppliers/suppliers/{id} → suppliers/{id}
6. shared/clients/procurement_client.py:
- get_supplier_by_id now uses SuppliersServiceClient directly
- Removes incorrect call to procurement service for supplier details
Impact:
- Demo session cloning now works without orchestrator errors ✅
- Consistent Redis usage across all services
- Correct service boundaries (suppliers data from suppliers service)
- Clean client endpoint paths
🤖 Generated with Claude Code (https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -33,7 +33,7 @@ from shared.clients.suppliers_client import SuppliersServiceClient
|
||||
from shared.clients.inventory_client import InventoryServiceClient
|
||||
from shared.config.base import BaseServiceSettings
|
||||
from shared.messaging import RabbitMQClient, UnifiedEventPublisher, EVENT_TYPES
|
||||
from app.utils.cache import delete_cached, make_cache_key
|
||||
from shared.redis_utils import get_keys_pattern, get_redis_client
|
||||
|
||||
logger = structlog.get_logger()
|
||||
|
||||
@@ -396,9 +396,18 @@ class PurchaseOrderService:
|
||||
await self.db.commit()
|
||||
|
||||
# PHASE 2: Invalidate purchase orders cache
|
||||
cache_key = make_cache_key("purchase_orders", str(tenant_id))
|
||||
await delete_cached(cache_key)
|
||||
logger.debug("Invalidated purchase orders cache", cache_key=cache_key, tenant_id=str(tenant_id))
|
||||
# Get all purchase order cache keys for this tenant and delete them
|
||||
try:
|
||||
cache_pattern = f"purchase_orders:{tenant_id}:*"
|
||||
client = await get_redis_client()
|
||||
if client:
|
||||
keys = await client.keys(cache_pattern)
|
||||
if keys:
|
||||
await client.delete(*keys)
|
||||
logger.debug("Invalidated purchase orders cache", pattern=cache_pattern, keys_deleted=len(keys), tenant_id=str(tenant_id))
|
||||
except Exception as e:
|
||||
logger.warning("Cache invalidation failed, continuing without cache invalidation",
|
||||
pattern=f"purchase_orders:{tenant_id}:*", error=str(e))
|
||||
|
||||
# Acknowledge PO approval alerts (non-blocking)
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user