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

   Follow-up to #69792, which made the Triggerer check that a deferring task's 
trigger classpath resolves to a `BaseTrigger` subclass before using it.
   
   `CallbackTrigger` resolves its `callback_path` with `import_string` and 
calls the result without checking what it is. This PR checks the callback path 
the same way trigger classpaths are checked. Before the callback runs, the 
resolved object must be one of:
   
   - a coroutine function (`async def`),
   - an awaitable callable, such as an async `BaseNotifier` subclass (has 
`__await__`),
   - a callable object whose `__call__` is `async def`.
   
   The first two are what `AsyncCallback.verify_callable` already requires when 
a deadline callback is defined. Triggerer callbacks are always awaited, so 
every documented use is still accepted. Modules, non-callable attributes, plain 
classes and sync functions now fail the callback with a clear 
`InvalidCallbackPathError` and are not called. Before this change, a sync 
function was called and only then failed with a "not awaitable" error. Like any 
other callback failure, the error is reported as a `FAILED` callback event and 
the Triggerer keeps running.
   
   Tests added:
   
   - unit tests for `_validate_callback`, one case each for accepted and 
rejected targets,
   - a `CallbackTrigger.run` test that resolves a real coroutine-function path,
   - a `CallbackTrigger.run` test that checks invalid paths (module, 
non-callable attribute, sync callable, plain class) fail without the target 
being called.
   
   ---
   ##### Was generative AI tooling used to co-author this PR?
   - [X] Yes (please specify the tool below)
   
   Generated-by: Claude Opus 5 following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   


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