Skip to content

Use Task SDK TaskInstanceState in OpenSearch log handler - #72444

Merged
kaxil merged 4 commits into
apache:mainfrom
atamagrawal:opensearch-sdk-task-instance-state
Oct 1, 2026
Merged

kaxil merged 4 commits into
apache:mainfrom
atamagrawal:opensearch-sdk-task-instance-state

Conversation

@atamagrawal

Copy link
Copy Markdown
Contributor

Replace the airflow.utils.state import with airflow.sdk in the OpenSearch task log
handler, so the provider relies on the Task SDK instead of airflow-core.

airflow.sdk.TaskInstanceState and airflow.utils.state.TaskInstanceState are two
independently defined (str, Enum) classes with matching member names and string values,
so this is a like-for-like import swap with no behaviour change. The provider requires
apache-airflow>=3.0.0, so airflow.sdk is always available and no version guard is
needed here, unlike providers that still support Airflow 2.11+.

Existing unit tests pass unmodified.

closes: #72409
related: #62063


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

Generated-by: Cursor (Claude Opus 5) following the guidelines


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

Atam Prakash Agrawal and others added 2 commits September 2, 2026 11:03
Replaces the airflow.utils.state import with airflow.sdk to reduce the
airflow-core dependency in the OpenSearch provider.

closes: apache#72409
@rawwar
rawwar self-requested a review September 2, 2026 17:00

@jroachgolf84 jroachgolf84 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please check the CI failures!

Airflow 3.0.6 does not export TaskInstanceState from airflow.sdk, so the
direct import breaks provider compatibility tests. Use the compat SDK shim
which falls back to airflow.utils.state on older 3.0.x releases.
@atamagrawal

Copy link
Copy Markdown
Contributor Author

@jroachgolf84

The CI failure was in the Airflow 3.0.6 compatibility job, not in the normal provider tests.
What broke: On Airflow 3.0.6, TaskInstanceState is not available from airflow.sdk. Our first change used:

from airflow.sdk import TaskInstanceState
That works on newer Airflow, but on 3.0.6 it fails at import time.

Fix: Import it through the compat layer already used in this file:

from airflow.providers.common.compat.sdk import AirflowException, TaskInstanceState, conf
On newer Airflow it uses airflow.sdk. On 3.0.6 it falls back to airflow.utils.state. Same behavior, compatibility tests pass.

@atamagrawal

Copy link
Copy Markdown
Contributor Author

@jroachgolf84 @rawwar Checking if you have comment or feedback on this PR.

@jroachgolf84 jroachgolf84 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approved!

@jroachgolf84

Copy link
Copy Markdown
Collaborator

cc: @rawwar - do you mind taking a look?

@atamagrawal

atamagrawal commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor Author

@jroachgolf84 , @rawwar Thanks, I see my PR is approved. But how can I merge it?

@kaxil
kaxil merged commit f3532c6 into apache:main Oct 1, 2026
98 checks passed
@boring-cyborg

boring-cyborg Bot commented Oct 1, 2026

Copy link
Copy Markdown

Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions.

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.

Replace airflow.utils.state import with airflow.sdk in OpenSearch Provider

4 participants