#22990·prefect

`dbt source freshness` logs are not associated with the enclosing task

Author: vyagubovCreated Aug 31, 2026Updated Sep 12, 2026
Labelsbug

Bug summary

When calling PrefectDbtRunner.invoke(['source', 'freshness', ...]) inside a Prefect task, logs from source node events appear in the flow run only — not in the task that called invoke().

Steps to reproduce

python
@task           
def run_source_freshness():                                                                                                                                                                   
    runner = PrefectDbtRunner(settings=project_settings)                                                                                                                                      
    runner.invoke(['source', 'freshness', '--target', env])                                                                                                                                   

Source freshness logs are missing from the run_source_freshness task logs and appear only at the flow level.

Expected behavior
Logs produced by PrefectDbtRunner.invoke() should appear in the enclosing task run (and propagate to the flow as usual).

Version info

Prefect 3.8.4
prefect-dbt 0.7.25
python 3.13.3

Additional context

No response