Skip to content

Fail AzureVirtualMachineStateSensor fast on an invalid target_state - #70372

Merged
shahar1 merged 1 commit into
apache:mainfrom
shahar1:fix-azure-vm-sensor-validation
Jul 24, 2026
Merged

Fail AzureVirtualMachineStateSensor fast on an invalid target_state#70372
shahar1 merged 1 commit into
apache:mainfrom
shahar1:fix-azure-vm-sensor-validation

Conversation

@shahar1

@shahar1 shahar1 commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

AI Summary

Follow-up to #70329, which correctly moved the target_state check out of __init__ (it is a template field, so the constructor only ever sees the un-rendered Jinja expression) but landed it in poke().

poke() runs inside the error handling of BaseSensorOperator.execute():

  • silent_fail=True — the ValueError is logged and turned into poke_return = False, so a misconfigured sensor keeps polling until its timeout (7 days by default) instead of failing.
  • never_fail=True / soft_fail=True — it is converted to AirflowSkipException, so the sensor reports no failure at all and downstream tasks proceed. A typo such as target_state="Running" (VALID_STATES are 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 uses silent_fail=True so it fails if the check ever moves back into poke().

related: #70296


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 4.8)

Generated-by: Claude Code (Opus 4.8) following the guidelines

@shahar1
shahar1 force-pushed the fix-azure-vm-sensor-validation branch from 6973229 to 4fc8b01 Compare July 24, 2026 09:23
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
shahar1 force-pushed the fix-azure-vm-sensor-validation branch from 4fc8b01 to 4e5a725 Compare July 24, 2026 09:26
@shahar1
shahar1 requested review from eladkal and vincbeck July 24, 2026 09:39
@shahar1
shahar1 merged commit ee142ce into apache:main Jul 24, 2026
83 checks passed
@shahar1
shahar1 deleted the fix-azure-vm-sensor-validation branch July 24, 2026 12:07
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.

2 participants