Skip to content

fix: prevent early return in check_for_write_conflict loop#64062

Open
Kundan-CR7 wants to merge 6 commits intoapache:mainfrom
Kundan-CR7:fix-variable-conflict-loop
Open

fix: prevent early return in check_for_write_conflict loop#64062
Kundan-CR7 wants to merge 6 commits intoapache:mainfrom
Kundan-CR7:fix-variable-conflict-loop

Conversation

@Kundan-CR7
Copy link

Fixes a logic issue in Variable.check_for_write_conflict where a return None
statement was placed inside the loop iterating over secrets backends.

Because of this, the function exited after the first iteration, preventing
remaining backends from being checked. This could lead to missed conflict detection
in environments with multiple secrets backends.

The fix moves the return None statement outside the loop so that all backends
are evaluated before returning.

This change corrects the control flow without introducing any new behavior.

closes: #64060

@Kundan-CR7 Kundan-CR7 requested review from XD-DENG and ashb as code owners March 22, 2026 13:39
@boring-cyborg
Copy link

boring-cyborg bot commented Mar 22, 2026

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

Copy link
Contributor

@SameerMesiah97 SameerMesiah97 left a comment

Choose a reason for hiding this comment

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

Looks fine. It seems like this codepath is not currently covered by tests so I think you should add one. A simple case where the first backend returns None and a later one returns a value should be enough.

CI needs to be triggered.

@Kundan-CR7
Copy link
Author

@SameerMesiah97 Thanks for the suggestion! Added a test to cover multiple backends where the first returns None and a later one returns a value, ensuring all backends are checked.

@eladkal eladkal added this to the Airflow 3.1.9 milestone Mar 22, 2026
@eladkal eladkal added the type:bug-fix Changelog: Bug Fixes label Mar 22, 2026
@eladkal eladkal requested a review from kaxil March 22, 2026 17:53
@Kundan-CR7 Kundan-CR7 force-pushed the fix-variable-conflict-loop branch from 8302091 to ef202ae Compare March 22, 2026 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:bug-fix Changelog: Bug Fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Variable.check_for_write_conflict exits early due to return inside loop

4 participants