Fail AzureVirtualMachineStateSensor fast on an invalid target_state - #70372
Merged
Conversation
shahar1
force-pushed
the
fix-azure-vm-sensor-validation
branch
from
July 24, 2026 09:23
6973229 to
4fc8b01
Compare
target_state is a template field, so the rendered value can only be checked at run time. Checking it from poke() puts it inside the error handling of BaseSensorOperator.execute(): under silent_fail the error is logged and treated as "not ready yet", so a misconfigured sensor polls until its timeout (7 days by default) instead of failing; under never_fail or soft_fail it becomes a skip, so the sensor reports no failure at all and downstream tasks proceed. Checking once in execute(), before the poll loop and before deferring, keeps the run-time check the template field requires while restoring an immediate, unambiguous failure.
shahar1
force-pushed
the
fix-azure-vm-sensor-validation
branch
from
July 24, 2026 09:26
4fc8b01 to
4e5a725
Compare
eladkal
approved these changes
Jul 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AI Summary
Follow-up to #70329, which correctly moved the
target_statecheck out of__init__(it is a template field, so the constructor only ever sees the un-rendered Jinja expression) but landed it inpoke().poke()runs inside the error handling ofBaseSensorOperator.execute():silent_fail=True— theValueErroris logged and turned intopoke_return = False, so a misconfigured sensor keeps polling until itstimeout(7 days by default) instead of failing.never_fail=True/soft_fail=True— it is converted toAirflowSkipException, so the sensor reports no failure at all and downstream tasks proceed. A typo such astarget_state="Running"(VALID_STATESare lowercase) silently skips.It also re-ran on every poke.
Checking once in
execute(), before the poll loop and before deferring, keeps the run-time check the template field requires while restoring an immediate, unambiguous failure. The added test usessilent_fail=Trueso it fails if the check ever moves back intopoke().related: #70296
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Opus 4.8) following the guidelines