Skip to content

Return 410 for stale id in set rtif API#68902

Open
FrankYang0529 wants to merge 1 commit into
apache:mainfrom
FrankYang0529:airflow-66416
Open

Return 410 for stale id in set rtif API#68902
FrankYang0529 wants to merge 1 commit into
apache:mainfrom
FrankYang0529:airflow-66416

Conversation

@FrankYang0529

Copy link
Copy Markdown
Member

Why

A task whose operator sets overwrite_rtif_after_execution=True logs a 404 error when setting rtif. The server regenerates the task instance id (archiving the old one to history) via a retry or a clear. However, the worker's finalize() still overwrites
RTIF using the stale id.

How

When a TI id is missing from the live table but present in history, PUT /task-instances/{id}/rtif now returns 410 Gone instead of 404. The hearbeat API also uses this mechanism. The supervisor treats that 410 as an expected, skippable outcome (debug log, no error). A genuine 404 still propagates as a real error.

closes: #66416

Was generative AI tooling used to co-author this PR?
  • Yes - Claude Code with Opus 4.8

  • 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, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

@boring-cyborg boring-cyborg Bot added area:API Airflow's REST/HTTP API area:task-sdk labels Jun 23, 2026
@FrankYang0529 FrankYang0529 changed the title Use 410 for stale id in set rtif API Return 410 for stale id in set rtif API Jun 23, 2026
@FrankYang0529 FrankYang0529 marked this pull request as ready for review June 23, 2026 23:58
When a task whose operator sets overwrite_rtif_after_execution=True leaves
RUNNING via a retry or a clear, the server regenerates the task instance id
and archives the old one. finalize() still overwrites RTIF with the stale id,
so the API server returns 404 and the worker logs a spurious
error traceback on top of the task's real outcome. The RTIF will be wrote in next id.

Signed-off-by: PoAn Yang <payang@apache.org>
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 with overwrite_rtif_after_execution = True raises API_SERVER_ERROR: 404 Not Found in finalize when execute() fails

1 participant