Skip to content

Commit 8d63f59

Browse files
fat-catTWhenry3260
authored andcommitted
fix referenced before assignment problems
1 parent 374e96f commit 8d63f59

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

airflow-core/src/airflow/api_fastapi/common/exceptions.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,14 @@ def __init__(self):
179179
def exception_handler(self, request: Request, exc: SQLAlchemyError):
180180
exception_id = get_random_string()
181181
stacktrace = "".join(traceback.format_tb(exc.__traceback__))
182+
statement = getattr(exc, "statement", "hidden")
183+
orig_error = getattr(exc, "orig", "hidden")
182184
# SQLAlchemyError may not have statement/orig attributes; guard access
183185
log.exception("Error with id %s, statement: %s", exception_id, statement, exc_info=exc)
184186
if conf.get("api", "expose_stacktrace") == "True":
185187
message = f"Error with id {exception_id}, statement: {statement}\n{stacktrace}"
186-
statement = getattr(exc, "statement", None)
187-
orig_error = getattr(exc, "orig", None)
188+
statement = str(statement)
189+
orig_error = str(orig_error)
188190
else:
189191
message = (
190192
"Serious error when handling your request. Check logs for more details - "

0 commit comments

Comments
 (0)