ColtenOuO opened a new pull request, #67206:
URL: https://github.com/apache/airflow/pull/67206

   The execution API had two routes (`ti_run`, `ti_update_state`) wrapping 
their `session.execute` calls in `try/except SQLAlchemyError` and converting to 
`HTTPException(500, "Database error occurred")`. The TODO in 
`routes/task_instances.py` flagged this for replacement with FastAPI's [custom 
exception 
handlers](https://fastapi.tiangolo.com/tutorial/handling-errors/#install-custom-exception-handlers).
   
   This adds `@app.exception_handler(SQLAlchemyError)` alongside the existing 
catch-all in `execution_api/app.py`. The new handler logs the request 
path/method and returns `{"detail": "Database error occurred"}` with status 500 
— the same shape the routes produced before. The per-route `try/except` blocks 
are removed and bodies dedented (which accounts for most of the line churn).
   
   ### Scope note
   
   The TODO was only on `ti_update_state` (around the call to 
`session.execute(query)` that writes the new state + audit `Log`). However, 
`ti_run` had the **same** `try/except SQLAlchemyError` boilerplate without a 
TODO, doing literally the same translation. Once the global handler exists, 
both local catches become redundant, so this PR removes both for consistency 
rather than leaving the codebase in a half-migrated state.
   
   If reviewers prefer a strict TODO-only scope, I'm happy to revert the 
`ti_run` change and open a separate cleanup PR for it.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to