032: fix UnboundLocalError for db_name in validate_target_table_schema

db_name and backend were initialized inside the try block but referenced
in the except handler. If an exception occurred before their assignment
(e.g. in resolve_database_id), the except block would raise:
  cannot access local variable 'db_name' where it is not associated
Moved initialization before try with safe defaults.
This commit is contained in:
2026-06-04 23:59:11 +03:00
parent f6dc7c47e7
commit 102f48a0d2

View File

@@ -233,6 +233,9 @@ def validate_target_table_schema(
logger.reason("Querying target table schema",
extra={"payload": {"table": target_ref, "env": req.environment_id, "db_id": req.target_database_id}})
backend = ""
db_name = "unknown"
try:
executor = SupersetSqlLabExecutor(config_manager, req.environment_id)
executor.resolve_database_id(target_database_id=req.target_database_id)