AkhilaNenavath123 opened a new pull request, #49929: URL: https://github.com/apache/airflow/pull/49929
This PR improves the user experience by making database error messages in the Airflow Rest API more user-friendly and less technical. Specifically, it addresses issues related to unique constraint violations and general database errors by providing clear, actionable error messages without exposing technical SQL details to the user. **Problem:** When attempting to trigger a second DAG run with the same logical date as the first one, the UI displayed a generic unique_constraint error, which included SQL query details. This error was difficult for users to interpret, as it exposed database internals rather than providing a clear action for resolution.  **Solution:** This PR enhances the _UniqueConstraintErrorHandler and adds a new _DatabaseErrorHandler to handle database errors in a more user-friendly manner. The changes ensure that: - Users are shown clear, concise, and actionable error messages. - SQL technical details (e.g., SQL queries) are removed from user-facing messages. - Specific guidance is provided to help resolve issues like duplicate DAG run IDs or task IDs. **Key Changes:** **Improved Error Messages:** - Enhanced _UniqueConstraintErrorHandler to provide specific, user-friendly messages for unique constraint violations (e.g., DAG run ID, task ID, logical date). - Removed technical SQL details and provided clear guidance on how to resolve the issues. **New Database Error Handler:** - Added _DatabaseErrorHandler class to handle general database errors (e.g., OperationalError, ProgrammingError) with user-friendly messages like "Please try again later." **Refactor Exception Handling:** - Refactored exception handling in API routes to use the new user-friendly error messages and provide actionable guidance for database-related issues.  Issue Link: https://github.com/apache/airflow/pull/49034 -- 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]
