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

   ### Summary
   
   `DataFusionToolset._query()` catches `SQLSafetyError` (raised when generated 
SQL fails safety validation), logs it, and re-raises it unchanged. Nothing 
between here and pydantic-ai's tool manager catches a plain `SQLSafetyError` -- 
only `ModelRetry` is special-cased -- so it propagates all the way out and 
fails the task outright.
   
   Every other query-error path in this same method already gives the agent a 
chance to self-correct. This PR updates `SQLSafetyError` handling to follow 
suit, allowing the agent the opportunity to fix its mistake instead of crashing 
the task.
   
   ### Change
   
   - `DataFusionToolset._query()`: `SQLSafetyError` now raises `ModelRetry` 
(with
     the validation message) instead of propagating raw, matching how
     `QueryExecutionException` and `SQLToolset` already behave.
   - Updated `test_blocks_create_table_by_default` to assert on `ModelRetry`
     instead of the old crash-through `SQLSafetyError`.
   - Added `test_sql_syntax_error_raises_model_retry_not_crash`, covering the 
case
     that actually motivated this fix: a plain syntax typo, not a deliberate 
write
     attempt, verified against the real `SQLSafetyError` cause via `__cause__`.


-- 
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