From 124ae79c8390da61f8646eb3ce4844252cee2acd Mon Sep 17 00:00:00 2001 From: aitbc Date: Thu, 30 Apr 2026 10:58:07 +0200 Subject: [PATCH] Fix bare except patterns in coordinator-api - Fixed monitoring_dashboard.py: replaced bare except with ValueError, AttributeError - Fixed cross_chain_bridge_enhanced.py: replaced bare except with Exception (with logging) - Fixed enterprise_integration.py: replaced bare except with specific exceptions This starts Phase 3: Exception Handling Improvement --- apps/coordinator-api/src/app/routers/monitoring_dashboard.py | 2 +- .../src/app/services/cross_chain_bridge_enhanced.py | 4 +++- .../src/app/services/enterprise_integration.py | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/coordinator-api/src/app/routers/monitoring_dashboard.py b/apps/coordinator-api/src/app/routers/monitoring_dashboard.py index 9ff8f0e2..55781b00 100755 --- a/apps/coordinator-api/src/app/routers/monitoring_dashboard.py +++ b/apps/coordinator-api/src/app/routers/monitoring_dashboard.py @@ -258,7 +258,7 @@ def calculate_overall_metrics(health_data: dict[str, Any]) -> dict[str, Any]: time_str = service_health["response_time"].replace("s", "") total_response_time += float(time_str) response_time_count += 1 - except: + except (ValueError, AttributeError): pass # Determine overall status diff --git a/apps/coordinator-api/src/app/services/cross_chain_bridge_enhanced.py b/apps/coordinator-api/src/app/services/cross_chain_bridge_enhanced.py index 27198fc1..9de70755 100755 --- a/apps/coordinator-api/src/app/services/cross_chain_bridge_enhanced.py +++ b/apps/coordinator-api/src/app/services/cross_chain_bridge_enhanced.py @@ -450,7 +450,9 @@ class CrossChainBridgeService: ) self.session.execute(stmt) self.session.commit() - except: + except Exception: + # Database update failed, log but continue + logger.warning(f"Failed to update bridge request status to failed: {bridge_request_id}") pass async def _execute_atomic_swap(self, bridge_request: BridgeRequest) -> None: diff --git a/apps/coordinator-api/src/app/services/enterprise_integration.py b/apps/coordinator-api/src/app/services/enterprise_integration.py index f65b8dea..5329d911 100755 --- a/apps/coordinator-api/src/app/services/enterprise_integration.py +++ b/apps/coordinator-api/src/app/services/enterprise_integration.py @@ -392,7 +392,7 @@ class SAPIntegration(ERPIntegration): day = date_value[6:8] return f"{year}-{month}-{day}" return date_value - except: + except (ValueError, IndexError, AttributeError, TypeError): return date_value def _transform_numeric(self, value: str, transform: Dict[str, Any]) -> Union[str, int, float]: