Skip to content

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

Merged
dabla merged 12 commits into
apache:mainfrom
dabla:fix/serialization-defer-task-taskinstance
Jun 7, 2026
Merged

Fix task_defer method with non-JSON next_kwargs in TaskInstance#64714
dabla merged 12 commits into
apache:mainfrom
dabla:fix/serialization-defer-task-taskinstance

Conversation

@dabla

@dabla dabla commented Apr 4, 2026

Copy link
Copy Markdown
Contributor

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 Outdated
Comment thread airflow-core/src/airflow/models/taskinstance.py Outdated
Comment thread airflow-core/src/airflow/models/taskinstance.py Outdated
@dabla dabla requested a review from uranusjr May 10, 2026 15:09

@jscheffl jscheffl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is a test only PR meanwhile? Other changes went on main with another PR?

@dabla dabla merged commit 4d3f52b into apache:main Jun 7, 2026
78 checks passed
@github-actions

github-actions Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Backport failed to create: v3-2-test. View the failure log Run details

Note: As of Merging PRs targeted for Airflow 3.X
the committer who merges the PR is responsible for backporting the PRs that are bug fixes (generally speaking) to the maintenance branches.

In matter of doubt please ask in #release-management Slack channel.

Status Branch Result
v3-2-test Commit Link

You can attempt to backport this manually by running:

cherry_picker 4d3f52b v3-2-test

This should apply the commit to the v3-2-test branch and leave the commit in conflict state marking
the files that need manual conflict resolution.

After you have resolved the conflicts, you can continue the backport process by running:

cherry_picker --continue

If you don't have cherry-picker installed, see the installation guide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants