fix(api): degrade recent event readback failures
All checks were successful
CD Pipeline / workflow-shape (push) Successful in 1s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Successful in 2m26s
CD Pipeline / build-and-deploy (push) Successful in 4m41s
CD Pipeline / post-deploy-checks (push) Successful in 4m49s
All checks were successful
CD Pipeline / workflow-shape (push) Successful in 1s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Successful in 2m26s
CD Pipeline / build-and-deploy (push) Successful in 4m41s
CD Pipeline / post-deploy-checks (push) Successful in 4m49s
This commit is contained in:
@@ -118,6 +118,8 @@ class RecentEventsResponse(BaseModel):
|
||||
events: list[ChannelEventItem]
|
||||
total: int
|
||||
limit: int
|
||||
source_status: str = "ready"
|
||||
source_error: str | None = None
|
||||
|
||||
|
||||
class ChannelEventDossierItem(BaseModel):
|
||||
@@ -667,9 +669,26 @@ async def list_recent_events(
|
||||
),
|
||||
limit: int = Query(20, ge=1, le=100, description="最多返回筆數"),
|
||||
) -> dict[str, Any]:
|
||||
return await list_recent_channel_events(
|
||||
project_id=project_id,
|
||||
channel_type=channel_type,
|
||||
provider_prefix=provider_prefix,
|
||||
limit=limit,
|
||||
)
|
||||
try:
|
||||
return await list_recent_channel_events(
|
||||
project_id=project_id,
|
||||
channel_type=channel_type,
|
||||
provider_prefix=provider_prefix,
|
||||
limit=limit,
|
||||
)
|
||||
except Exception as exc:
|
||||
logger.warning(
|
||||
"recent_channel_events_source_unavailable",
|
||||
project_id=project_id or "awoooi",
|
||||
channel_type=channel_type,
|
||||
provider_prefix=provider_prefix,
|
||||
limit=limit,
|
||||
error=exc.__class__.__name__,
|
||||
)
|
||||
return {
|
||||
"events": [],
|
||||
"total": 0,
|
||||
"limit": max(1, min(limit, 100)),
|
||||
"source_status": "source_unavailable",
|
||||
"source_error": exc.__class__.__name__,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user