Skip to content

Fix task-level audit logs missing success/running events in Airflow 3.1.x#61932

Open
sjyangkevin wants to merge 1 commit intoapache:mainfrom
sjyangkevin:issues/58381/success-running-audit-logs-missing
Open

Fix task-level audit logs missing success/running events in Airflow 3.1.x#61932
sjyangkevin wants to merge 1 commit intoapache:mainfrom
sjyangkevin:issues/58381/success-running-audit-logs-missing

Conversation

@sjyangkevin
Copy link
Contributor

@sjyangkevin sjyangkevin commented Feb 15, 2026

closes: #58381

Issue

In Airflow 2, task instance state transition such as RUNNING, SUCCESS, SKIPPED, FAILED were logged into the log table through the TaskInstance model methods. In Airflow 3, the task state update/management is moved to the execution API endpoints ti_run and ti_update_state. However, the endpoints were not wired up to create log records, resulting in missing audit logs for task instance state transitions.

Fix

Added session.add(Log(...)) calls to both ti_run and ti_update_state when the task instance state is updated. The call will be executed in the same transaction as the state update in both endpoints.

In ti_run, the audit log is placed inside the else branch such that duplicated requests, or conflict request, due to network glitch, will not be logged.

In ti_update_state, the TI select query is updated to fetch task_id, run_id, and map_index.

Screenshot from 2026-02-14 19-13-44

Caveat

The following fields in the log table are missing. Require extra query/join to fetch the following information.

  • logical_date (previously execution_date)
  • owner (the value is airflow in Airflow 2)
  • owner_display_name (this field is also empty for task state transition)
  • extra (full_command will not be available as it is not run/update through CLI; hostname is not available in ti_update_state)

EmptyOperator or operators skipped by branch doesn't have audit log

Screenshot from 2026-02-14 22-24-31

DAG Test Samples

Screenshot from 2026-02-14 22-13-16
Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Generated-by: [Antigravity] following the guidelines

The tool is used to analyze the existing test cases to understand the expected behavior of both ti_run and ti_update_state. It is also used to generate new test cases.


  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

@boring-cyborg boring-cyborg bot added area:API Airflow's REST/HTTP API area:task-sdk labels Feb 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:API Airflow's REST/HTTP API area:task-sdk

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Task-level audit logs missing SUCCESS/RUNNING events in Airflow 3.1.x (only FAILED and state mismatch recorded)

1 participant