From 4b1cb5520b67cd1a9c34d787db62389a542e2832 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rmungandrk?= Date: Sun, 22 Feb 2026 16:37:39 +0700 Subject: [PATCH] Fix schema plugin unreachable except block --- .../sql_schema_plugin.py | 32 ++++++++----------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/application/single_app/semantic_kernel_plugins/sql_schema_plugin.py b/application/single_app/semantic_kernel_plugins/sql_schema_plugin.py index 01d89aa2..d321338c 100644 --- a/application/single_app/semantic_kernel_plugins/sql_schema_plugin.py +++ b/application/single_app/semantic_kernel_plugins/sql_schema_plugin.py @@ -298,40 +298,36 @@ def get_database_schema( } ) - except Exception as e: - error_msg = f"Failed to get database schema: {str(e)}" - print(f"[SQLSchemaPlugin] ERROR: {error_msg}") - log_event(f"[SQLSchemaPlugin] get_database_schema failed", extra={ - "error": str(e), - "database_type": self.database_type, - "database": self.database - }) - return ResultWithMetadata( - {"error": error_msg}, - {"source": "sql_schema_plugin", "success": False} - ) - # Get tables tables_query = self._get_tables_query(include_system_tables, table_filter) cursor.execute(tables_query) tables = cursor.fetchall() - + # Get schema for each table for table_row in tables: table_name = table_row[0] if isinstance(table_row, (list, tuple)) else table_row table_schema = self._get_table_schema_data(cursor, table_name) schema_data["tables"][table_name] = table_schema - + # Get relationships relationships = self._get_relationships_data(cursor) schema_data["relationships"] = relationships - + log_event(f"[SQLSchemaPlugin] Retrieved schema for {len(schema_data['tables'])} tables") return ResultWithMetadata(schema_data, self.metadata) except Exception as e: - log_event(f"[SQLSchemaPlugin] Error getting database schema: {e}") - raise + error_msg = f"Failed to get database schema: {str(e)}" + print(f"[SQLSchemaPlugin] ERROR: {error_msg}") + log_event(f"[SQLSchemaPlugin] get_database_schema failed", extra={ + "error": str(e), + "database_type": self.database_type, + "database": self.database + }) + return ResultWithMetadata( + {"error": error_msg}, + {"source": "sql_schema_plugin", "success": False} + ) @kernel_function(description="Get detailed schema for a specific table") @plugin_function_logger("SQLSchemaPlugin")