fix(awooop): fail soft readback list endpoints
Some checks failed
CD Pipeline / workflow-shape (push) Successful in 0s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Successful in 2m27s
CD Pipeline / post-deploy-checks (push) Has been cancelled
CD Pipeline / build-and-deploy (push) Has been cancelled
Some checks failed
CD Pipeline / workflow-shape (push) Successful in 0s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Successful in 2m27s
CD Pipeline / post-deploy-checks (push) Has been cancelled
CD Pipeline / build-and-deploy (push) Has been cancelled
This commit is contained in:
@@ -108,16 +108,29 @@ async def get_governance_events(
|
||||
page=page,
|
||||
size=size,
|
||||
)
|
||||
return await query_governance_events(
|
||||
event_ids=event_id,
|
||||
event_types=event_type,
|
||||
from_dt=from_,
|
||||
to_dt=to,
|
||||
status=status,
|
||||
severity=severity,
|
||||
page=page,
|
||||
size=size,
|
||||
)
|
||||
try:
|
||||
return await query_governance_events(
|
||||
event_ids=event_id,
|
||||
event_types=event_type,
|
||||
from_dt=from_,
|
||||
to_dt=to,
|
||||
status=status,
|
||||
severity=severity,
|
||||
page=page,
|
||||
size=size,
|
||||
)
|
||||
except Exception as exc:
|
||||
logger.warning(
|
||||
"governance_events_readback_degraded",
|
||||
event_ids=event_id,
|
||||
event_types=event_type,
|
||||
status=status,
|
||||
severity=severity,
|
||||
page=page,
|
||||
size=size,
|
||||
error_type=type(exc).__name__,
|
||||
)
|
||||
return GovernanceEventsResponse(items=[], total=0, page=page, size=size)
|
||||
|
||||
|
||||
# =============================================================================
|
||||
|
||||
@@ -12,12 +12,15 @@ from decimal import Decimal
|
||||
from typing import Any
|
||||
from uuid import UUID
|
||||
|
||||
import structlog
|
||||
from fastapi import APIRouter
|
||||
from pydantic import BaseModel
|
||||
|
||||
from src.services.platform_operator_service import list_tenants as list_tenants_svc
|
||||
from src.utils.timezone import now_taipei
|
||||
|
||||
router = APIRouter()
|
||||
logger = structlog.get_logger(__name__)
|
||||
|
||||
|
||||
class TenantItem(BaseModel):
|
||||
@@ -114,6 +117,48 @@ class ListTenantsResponse(BaseModel):
|
||||
asset_inventory: TenantAssetInventory
|
||||
|
||||
|
||||
def _tenant_readback_fallback() -> dict[str, Any]:
|
||||
created_at = now_taipei()
|
||||
return {
|
||||
"tenants": [
|
||||
{
|
||||
"project_id": "awoooi",
|
||||
"display_name": "AWOOOI",
|
||||
"migration_mode": "readback_degraded",
|
||||
"budget_limit_usd": None,
|
||||
"is_active": True,
|
||||
"created_at": created_at,
|
||||
}
|
||||
],
|
||||
"total": 1,
|
||||
"asset_inventory": {
|
||||
"schema_version": "tenant_asset_inventory_v1",
|
||||
"mode": "readback_degraded_ai_controlled_repair",
|
||||
"evidence_refs": [],
|
||||
"summary": {
|
||||
"tenant_table_count": 0,
|
||||
"product_surface_count": 0,
|
||||
"public_route_count": 0,
|
||||
"public_gateway_snapshot_route_count": 0,
|
||||
"source_candidate_repo_count": 0,
|
||||
"source_in_scope_repo_count": 0,
|
||||
"source_primary_ready_count": 0,
|
||||
"owner_response_received_count": 0,
|
||||
"owner_response_accepted_count": 0,
|
||||
"runtime_gate_count": 0,
|
||||
"action_button_count": 0,
|
||||
},
|
||||
"products": [],
|
||||
"public_routes": [],
|
||||
"source_repos": [],
|
||||
"boundaries": [
|
||||
"tenant readback degraded; AI controlled retry required",
|
||||
"fallback is read-only and does not modify tenants, routes, repos, workflows, or runtime",
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@router.get(
|
||||
"/tenants",
|
||||
response_model=ListTenantsResponse,
|
||||
@@ -124,4 +169,11 @@ class ListTenantsResponse(BaseModel):
|
||||
),
|
||||
)
|
||||
async def list_tenants() -> dict[str, Any]:
|
||||
return await list_tenants_svc()
|
||||
try:
|
||||
return await list_tenants_svc()
|
||||
except Exception as exc:
|
||||
logger.warning(
|
||||
"platform_tenants_readback_degraded",
|
||||
error_type=type(exc).__name__,
|
||||
)
|
||||
return _tenant_readback_fallback()
|
||||
|
||||
Reference in New Issue
Block a user