You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "nandeshkanagaraju (via GitHub)" <gi...@apache.org> on 2026/09/07 11:24:06 UTC

[PR] Fix region_name being ignored by the Step Functions execution trigger [airflow]

nandeshkanagaraju opened a new pull request, #72625:
URL: https://github.com/apache/airflow/pull/72625

   StepFunctionsExecutionCompleteTrigger accepted region_name but only put it into serialized_fields without forwarding it to AwsBaseWaiterTrigger, so self.region_name stayed None and the deferred waiter always polled Step Functions in the default region instead of the one the operator was configured with. The base class already serializes region_name itself, so the serialized_fields entry was redundant on top of being inert.
   
   Also adds the previously missing dedicated test module for the trigger (tracked in the OVERLOOKED_TESTS allowlist), including a regression test that fails without this fix.
   
   Claude-Session: https://claude.ai/code/session_01QL3YuSRJuK6WpZGc4jMjd1
   
    <!-- SPDX-License-Identifier: Apache-2.0
         https://www.apache.org/licenses/LICENSE-2.0 -->
   
   <!--
   Thank you for contributing!
   
   Please provide above a brief description of the changes made in this pull request.
   Write a good git commit message following this guide: https://chris.beams.io/posts/git-commit/
   
   Please make sure that your code changes are covered with tests.
   And in case of new features or big changes remember to adjust the documentation.
   
   For user-facing UI changes, please attach before/after screenshots (or a short
   screen recording) so reviewers can assess the visual impact.
   
   Feel free to ping (in general) for the review if you do not see reaction for a few days
   (72 Hours is the minimum reaction time you can expect from volunteers) - we sometimes miss notifications.
   
   In case of an existing issue, reference it using one of the following:
   
   * closes: #ISSUE
   * related: #ISSUE
   -->
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   <!--
   If generative AI tooling has been used in the process of authoring this PR, please
   change below checkbox to `[X]` followed by the name of the tool, uncomment the "Generated-by".
   -->
   
   - [ ] Yes (please specify the tool below)
   
   <!--
   Generated-by: [Tool Name] following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   -->
   
   ---
   
   * Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#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](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
   * When adding dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   * For significant user-facing changes create newsfragment: `{pr_number}.significant.rst`, in [airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments). You can add this file in a follow-up commit after the PR is created so you know the PR number.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix region_name being ignored by the Step Functions execution trigger [airflow]

Posted by "nandeshkanagaraju (via GitHub)" <gi...@apache.org>.
nandeshkanagaraju commented on code in PR #72625:
URL: https://github.com/apache/airflow/pull/72625#discussion_r3960722108


##########
providers/amazon/tests/unit/amazon/aws/triggers/test_step_function.py:
##########
@@ -0,0 +1,89 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+from unittest import mock
+from unittest.mock import AsyncMock
+
+import pytest
+
+from airflow.providers.amazon.aws.hooks.step_function import StepFunctionHook
+from airflow.providers.amazon.aws.triggers.step_function import StepFunctionsExecutionCompleteTrigger
+from airflow.triggers.base import TriggerEvent
+
+BASE_TRIGGER_CLASSPATH = "airflow.providers.amazon.aws.triggers.step_function."
+
+
+class TestStepFunctionsExecutionCompleteTrigger:
+    EXPECTED_WAITER_NAME = "step_function_succeeded"
+    EXECUTION_ARN = (
+        "arn:aws:states:us-east-1:123456789012:execution:"
+        "pseudo-state-machine:020f5b16-b1a1-4149-946f-92dd32d97934"
+    )
+
+    def test_serialization(self):

Review Comment:
   Good catch — confirmed by reverting the production change locally: only `test_hook_forwards_connection_config` fails, while `test_serialization` and `test_run_success` pass either way. I've named it as the regression test in the PR description and marked the other two as module coverage.
   
   ---
   Drafted-by: Claude Code (Opus 5); reviewed by @nandeshkanagaraju before posting
   



##########
providers/amazon/tests/unit/amazon/aws/triggers/test_step_function.py:
##########
@@ -0,0 +1,89 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+from unittest import mock
+from unittest.mock import AsyncMock
+
+import pytest
+
+from airflow.providers.amazon.aws.hooks.step_function import StepFunctionHook
+from airflow.providers.amazon.aws.triggers.step_function import StepFunctionsExecutionCompleteTrigger
+from airflow.triggers.base import TriggerEvent
+
+BASE_TRIGGER_CLASSPATH = "airflow.providers.amazon.aws.triggers.step_function."
+
+
+class TestStepFunctionsExecutionCompleteTrigger:
+    EXPECTED_WAITER_NAME = "step_function_succeeded"
+    EXECUTION_ARN = (
+        "arn:aws:states:us-east-1:123456789012:execution:"
+        "pseudo-state-machine:020f5b16-b1a1-4149-946f-92dd32d97934"
+    )
+
+    def test_serialization(self):
+        trigger = StepFunctionsExecutionCompleteTrigger(
+            execution_arn=self.EXECUTION_ARN,
+            waiter_delay=10,
+            waiter_max_attempts=5,
+            aws_conn_id="aws_step_function_conn",
+            region_name="eu-central-1",
+        )
+
+        classpath, kwargs = trigger.serialize()
+
+        assert classpath == BASE_TRIGGER_CLASSPATH + "StepFunctionsExecutionCompleteTrigger"
+        assert kwargs.get("execution_arn") == self.EXECUTION_ARN
+        assert kwargs.get("waiter_delay") == 10
+        assert kwargs.get("waiter_max_attempts") == 5
+        assert kwargs.get("aws_conn_id") == "aws_step_function_conn"
+        assert kwargs.get("region_name") == "eu-central-1"
+
+    def test_hook_forwards_connection_config(self):
+        trigger = StepFunctionsExecutionCompleteTrigger(
+            execution_arn=self.EXECUTION_ARN,
+            aws_conn_id="aws_step_function_conn",
+            region_name="eu-central-1",
+            verify=False,
+            botocore_config={"read_timeout": 100},
+        )
+
+        hook = trigger.hook()
+
+        assert isinstance(hook, StepFunctionHook)
+        assert hook.aws_conn_id == "aws_step_function_conn"
+        assert hook._region_name == "eu-central-1"
+        assert hook._verify is False
+        assert hook._config.read_timeout == 100
+
+    @pytest.mark.asyncio
+    @mock.patch.object(StepFunctionHook, "get_waiter")
+    @mock.patch.object(StepFunctionHook, "get_async_conn")
+    async def test_run_success(self, mock_async_conn, mock_get_waiter):
+        mock_async_conn.__aenter__.return_value = mock.MagicMock()

Review Comment:
   Applied in acc5052, thanks. Verified against `test_ec2.py` — you're right that the original line set `__aenter__` on the patched method rather than on its return value, so it was a no-op and the test only passed because `AsyncMock` auto-creates the context manager.
   
   ---
   Drafted-by: Claude Code (Opus 5); reviewed by @nandeshkanagaraju before posting
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix region_name being ignored by the Step Functions execution trigger [airflow]

Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on PR #72625:
URL: https://github.com/apache/airflow/pull/72625#issuecomment-5604957444

   Awesome work, congrats on your first merged pull request! You are invited to check our [Issue Tracker](https://github.com/apache/airflow/issues) for additional contributions.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix region_name being ignored by the Step Functions execution trigger [airflow]

Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on PR #72625:
URL: https://github.com/apache/airflow/pull/72625#issuecomment-5569896787

   Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our [Contributors' Guide](https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
   Here are some useful points:
   - Pay attention to the quality of your code (ruff, mypy and type annotations). Our [prek-hooks]( https://github.com/apache/airflow/blob/main/contributing-docs/08_static_code_checks.rst#prerequisites-for-prek-hooks) will help you with that.
   - In case of a new feature add useful documentation (in docstrings or in `docs/` directory). Adding a new operator? Check this short [guide](https://github.com/apache/airflow/blob/main/airflow-core/docs/howto/custom-operator.rst) Consider adding an example Dag that shows how users should use it.
   - Consider using [Breeze environment](https://github.com/apache/airflow/blob/main/dev/breeze/doc/README.rst) for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
   - Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
   - Please follow [ASF Code of Conduct](https://www.apache.org/foundation/policies/conduct) for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
   - Be sure to read the [Airflow Coding style]( https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#coding-style-and-best-practices).
   - Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
   Apache Airflow is a community-driven project and together we are making it better 🚀.
   In case of doubts contact the developers at:
   Mailing List: dev@airflow.apache.org
   Slack: https://s.apache.org/airflow-slack
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix region_name being ignored by the Step Functions execution trigger [airflow]

Posted by "rjgoyln (via GitHub)" <gi...@apache.org>.
rjgoyln commented on code in PR #72625:
URL: https://github.com/apache/airflow/pull/72625#discussion_r3960492687


##########
providers/amazon/tests/unit/amazon/aws/triggers/test_step_function.py:
##########
@@ -0,0 +1,89 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+from unittest import mock
+from unittest.mock import AsyncMock
+
+import pytest
+
+from airflow.providers.amazon.aws.hooks.step_function import StepFunctionHook
+from airflow.providers.amazon.aws.triggers.step_function import StepFunctionsExecutionCompleteTrigger
+from airflow.triggers.base import TriggerEvent
+
+BASE_TRIGGER_CLASSPATH = "airflow.providers.amazon.aws.triggers.step_function."
+
+
+class TestStepFunctionsExecutionCompleteTrigger:
+    EXPECTED_WAITER_NAME = "step_function_succeeded"
+    EXECUTION_ARN = (
+        "arn:aws:states:us-east-1:123456789012:execution:"
+        "pseudo-state-machine:020f5b16-b1a1-4149-946f-92dd32d97934"
+    )
+
+    def test_serialization(self):

Review Comment:
   This test passes with or without the production change, as `region_name` was already preserved during serialization. `test_serialize_recreate` also covers this round trip.
   
   Fine to keep for coverage, but the actual regression test is `test_hook_forwards_connection_config`. It may be worth naming it in the description for clarity.
   



##########
providers/amazon/tests/unit/amazon/aws/triggers/test_step_function.py:
##########
@@ -0,0 +1,89 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+from unittest import mock
+from unittest.mock import AsyncMock
+
+import pytest
+
+from airflow.providers.amazon.aws.hooks.step_function import StepFunctionHook
+from airflow.providers.amazon.aws.triggers.step_function import StepFunctionsExecutionCompleteTrigger
+from airflow.triggers.base import TriggerEvent
+
+BASE_TRIGGER_CLASSPATH = "airflow.providers.amazon.aws.triggers.step_function."
+
+
+class TestStepFunctionsExecutionCompleteTrigger:
+    EXPECTED_WAITER_NAME = "step_function_succeeded"
+    EXECUTION_ARN = (
+        "arn:aws:states:us-east-1:123456789012:execution:"
+        "pseudo-state-machine:020f5b16-b1a1-4149-946f-92dd32d97934"
+    )
+
+    def test_serialization(self):
+        trigger = StepFunctionsExecutionCompleteTrigger(
+            execution_arn=self.EXECUTION_ARN,
+            waiter_delay=10,
+            waiter_max_attempts=5,
+            aws_conn_id="aws_step_function_conn",
+            region_name="eu-central-1",
+        )
+
+        classpath, kwargs = trigger.serialize()
+
+        assert classpath == BASE_TRIGGER_CLASSPATH + "StepFunctionsExecutionCompleteTrigger"
+        assert kwargs.get("execution_arn") == self.EXECUTION_ARN
+        assert kwargs.get("waiter_delay") == 10
+        assert kwargs.get("waiter_max_attempts") == 5
+        assert kwargs.get("aws_conn_id") == "aws_step_function_conn"
+        assert kwargs.get("region_name") == "eu-central-1"
+
+    def test_hook_forwards_connection_config(self):
+        trigger = StepFunctionsExecutionCompleteTrigger(
+            execution_arn=self.EXECUTION_ARN,
+            aws_conn_id="aws_step_function_conn",
+            region_name="eu-central-1",
+            verify=False,
+            botocore_config={"read_timeout": 100},
+        )
+
+        hook = trigger.hook()
+
+        assert isinstance(hook, StepFunctionHook)
+        assert hook.aws_conn_id == "aws_step_function_conn"
+        assert hook._region_name == "eu-central-1"
+        assert hook._verify is False
+        assert hook._config.read_timeout == 100
+
+    @pytest.mark.asyncio
+    @mock.patch.object(StepFunctionHook, "get_waiter")
+    @mock.patch.object(StepFunctionHook, "get_async_conn")
+    async def test_run_success(self, mock_async_conn, mock_get_waiter):
+        mock_async_conn.__aenter__.return_value = mock.MagicMock()

Review Comment:
   Missing a `.return_value` — `get_async_conn` is the patched method, so the async context manager lives on its return value:
   
   ```suggestion
           mock_async_conn.return_value.__aenter__.return_value = mock.MagicMock()
   ```
   
   As written the line is a no-op and the test only passes because `AsyncMock` auto-creates the context manager. Several existing trigger tests in this directory carry the same typo, so this is inherited rather than introduced; `test_ec2.py` has the correct form if you want a reference.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix region_name being ignored by the Step Functions execution trigger [airflow]

Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck merged PR #72625:
URL: https://github.com/apache/airflow/pull/72625


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org