Repository navigation
Python: fix(declarative): honor the variable field in SetValue - #9428
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The narrow fix matches the builder’s existing contract and includes focused regression coverage.
0 open findings
What changed in this PR
Fixes #9427 by making Python’s declarative SetValue executor honor the variable alias already accepted by the builder.
Changes:
- Reuses
_get_variable_pathwhenpathis absent. - Adds regression tests for string and nested-object aliases, plus
pathprecedence.
| File | Description |
|---|---|
| python/packages/declarative/tests/test_graph_coverage.py | Tests both alias forms and explicit-path precedence. |
| python/packages/declarative/agent_framework_declarative/_workflows/_executors_basic.py | Adds the variable-path fallback. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Bicheng (Kenneth) (BichengWang)
left a comment
There was a problem hiding this comment.
Reviewed 8cdf12d62ca3b8342a469b29af027906fe66acee against cae49553ce7f1c54edec97ad97fb820fd792175d.
The fallback matches the builder's existing SetValue.path alias contract. Keeping the direct path lookup first preserves precedence when both fields are present, while _get_variable_path handles both the string and nested mapping forms. Value evaluation and completion signaling stay on the existing execution path. I found no correctness regression in the diff.
I checked the regression independently on macOS with Python 3.13.16:
- With the base version of
_executors_basic.py, the two new alias cases fail withNoneinstead of the assigned value; the precedence case passes. Restoring this head gives 3 passed. - The declarative non-integration suite gives 1,154 passed, 501 skipped. The skips are PowerFx-dependent tests; the required runtime is unavailable here. This used the checked-out core and declarative source via
PYTHONPATH, pytest 9.1.1, and mcp 2.3.0, without credentials or live service calls. - I also ran an actual YAML workflow through
WorkflowFactoryand inspected its final checkpoint. String and nested aliases persist their values, directpathwins without creating the alias target, and false/zero/null values are retained. The same workflow loses the alias assignments with the base executor.
One suggested test improvement: retain a factory/checkpoint regression in the suite for both alias shapes. The new tests exercise the executor with a mocked context, while the existing builder test only checks that the definition builds; a real workflow test would protect their agreement without needing PowerFx or a service.
Before merge, #9427 still needs explicit maintainer agreement under CONTRIBUTING.md: at review time its only reply is automated triage and it has no ready-for-implementation label.
|
Bicheng (Kenneth) (@BichengWang) thanks for running it end to end. Added that test in 8d8053c: It's its own class without the PowerFx marker, since the values are literals, so it runs without a .NET runtime. With the base executor both cases fail with |
Motivation & Context
The builder accepts
variablein place ofpathforSetValue(ACTION_ALTERNATE_FIELDS["SetValue.path"],_declarative_builder.py:99), and there is a test that checks this builds. ButSetValueExecutoronly readpath, so aSetValuewritten withvariable:built fine and then wrote nothing. No error, the variable just stayed unset.Description & Review Guide
SetValueExecutornow falls back to_get_variable_pathwhenpathis missing. That's the same helperSetVariableuses, so bothvariable: Local.xandvariable: {path: Local.x}work. One line in_executors_basic.py, plus tests intest_graph_coverage.pyfor both shapes and forpathwinning when both are set.path:behaves the same.pathstill wins if both are set. YAML that usedvariable:now sets the value instead of silently skipping it."SetValue.path": ["variable"]from the builder so it fails at build time. I went with the alias because the builder and its test already treat it as valid.Test before the fix:
After:
uv run poe test -P declarative, with the fix reverted and then with it:The 501 skips are the PowerFx tests, my machine has no .NET runtime.
poe syntax -P declarativeandpoe typing -P declarativepass.Related Issue
Fixes #9427
AI Assistance
AI assistance details: An AI assistant helped find the bug, write the fix and test, and draft this description. I ran the repro and the tests myself.
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.