Validate AzureVirtualMachineStateSensor target_state after rendering - #70329
Merged
Conversation
target_state is a template field, so it is rendered after __init__ runs. The
constructor validated it against VALID_STATES and raised ValueError there, so a
templated target_state (e.g. "{{ params.state }}") could never be built: __init__
saw the un-rendered expression and rejected it. Move the check into poke(), which
runs after rendering, and store target_state verbatim in the constructor.
related: apache#70296
Signed-off-by: 1fanwang <1fannnw@gmail.com>
1fanwang
requested review from
amoghrajesh,
ashb,
bugraoz93,
gopidesupavan,
jason810496,
jscheffl and
potiuk
as code owners
July 23, 2026 20:57
1fanwang
marked this pull request as draft
July 24, 2026 05:47
Signed-off-by: 1fanwang <1fannnw@gmail.com>
1fanwang
marked this pull request as ready for review
July 24, 2026 06:23
shahar1
approved these changes
Jul 24, 2026
1 task
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.
target_stateis a template field, so it is rendered after__init__runs.AzureVirtualMachineStateSensorvalidated it againstVALID_STATESand raisedValueErrorin the constructor, so a templatedtarget_statecould never be built —__init__saw the un-rendered Jinja expression and rejected it:Store
target_stateverbatim in the constructor and move the check intopoke(), which runs after rendering (both the synchronous and deferrable paths reachpoke()before using the value).related: #70296
Testing Done
Reverting only the source and running the new tests reproduces the bug:
With the fix,
test_compute.py: 9 passed.validate_operators_init.pyon the sensor exits 0 (the constructor no longer reads the template field).Was generative AI tooling used to co-author this PR?
Generated-by: GitHub Copilot CLI following the guidelines