Skip to content

Pass impersonation_chain to the Dataflow trigger for Beam Java/Python operators - #72210

Open
afonsojanu wants to merge 1 commit into
apache:mainfrom
afonsojanu:fix/beam-dataflow-trigger-impersonation-chain-72135
Open

Pass impersonation_chain to the Dataflow trigger for Beam Java/Python operators#72210
afonsojanu wants to merge 1 commit into
apache:mainfrom
afonsojanu:fix/beam-dataflow-trigger-impersonation-chain-72135

Conversation

@afonsojanu

Copy link
Copy Markdown

Fixes #72135

BeamRunJavaPipelineOperator and BeamRunPythonPipelineOperator both use self.dataflow_config.impersonation_chain when running the pipeline directly, but when deferrable mode is on and they build trigger_args for DataflowJobStatusTrigger / DataflowJobStateCompleteTrigger, that value never gets passed through. So a deferred task ends up polling Dataflow for completion with whatever credentials the worker has, not the impersonated account the operator was configured with.

Both trigger classes already accept impersonation_chain in their constructor (see airflow/providers/google/cloud/triggers/dataflow.py), so this is just a matter of including it in the dict the operators build.

While looking at this I noticed the exact same pattern shows up in both operators, the Java one that the issue reports and the Python one that wasn't reported but has the identical bug, so I fixed both.

I added a test for each operator asserting the trigger it raises actually carries the configured impersonation_chain. I couldn't run the full provider test suite locally since it needs the breeze dev environment, but I verified the fix against the real installed package by patching in the modified module and driving it through the exact same code path the tests exercise, confirming it fails without the change (impersonation_chain comes through as None) and passes with it.

Ran ruff on both changed files with no issues.

… operators

BeamRunJavaPipelineOperator and BeamRunPythonPipelineOperator both read
self.dataflow_config.impersonation_chain when running the pipeline itself,
but when deferrable mode kicks in and they build the trigger_args dict
for DataflowJobStatusTrigger or DataflowJobStateCompleteTrigger, that
field never makes it in. So a job that's meant to poll for completion
under an impersonated service account ends up polling with whatever
credentials the worker happens to have instead.

Added impersonation_chain to both trigger_args dicts, and a test for
each operator that checks the trigger actually receives it.
@boring-cyborg

boring-cyborg Bot commented Aug 28, 2026

Copy link
Copy Markdown

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
Here are some useful points:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our 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 Consider adding an example Dag that shows how users should use it.
  • Consider using Breeze environment 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 for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
  • 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

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BeamRunJavaPipelineOperator deferrable impersonation chain issue

1 participant