Skip to content

Fix task_defer method with non-JSON next_kwargs in TaskInstance#64714

Open
dabla wants to merge 3 commits intoapache:mainfrom
dabla:fix/serialization-defer-task-taskinstance
Open

Fix task_defer method with non-JSON next_kwargs in TaskInstance#64714
dabla wants to merge 3 commits intoapache:mainfrom
dabla:fix/serialization-defer-task-taskinstance

Conversation

@dabla
Copy link
Copy Markdown
Contributor

@dabla dabla commented Apr 4, 2026

Fix serialization in task_defer method with non-JSON next_kwargs of TaskInstance as mentioned by @kaxil in PR #55068.


Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

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

@dabla dabla requested review from XD-DENG and ashb as code owners April 4, 2026 12:19
@eladkal eladkal added this to the Airflow 3.2.1 milestone Apr 7, 2026
@eladkal eladkal added the backport-to-v3-2-test Mark PR with this label to backport to v3-2-test branch label Apr 7, 2026
@eladkal eladkal requested a review from kaxil April 7, 2026 05:44
@kaxil kaxil requested a review from Copilot April 10, 2026 19:55
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Fixes TaskInstance.defer_task() so next_kwargs containing non-JSON-serializable objects (e.g., datetime, timedelta) are converted into a JSON-safe form before being persisted.

Changes:

  • Serialize start_trigger_args.next_kwargs via Airflow SDK serde before assigning to TaskInstance.next_kwargs.
  • Add a unit test covering defer_task() with non-JSON-native next_kwargs values.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
airflow-core/src/airflow/models/taskinstance.py Serializes next_kwargs during deferral to avoid non-JSON values being stored.
airflow-core/tests/unit/models/test_taskinstance.py Adds regression test verifying serde roundtrip for non-JSON next_kwargs.

Comment thread airflow-core/tests/unit/models/test_taskinstance.py
Comment thread airflow-core/src/airflow/models/taskinstance.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-to-v3-2-test Mark PR with this label to backport to v3-2-test branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants