Skip to content

Python: Add regression tests for Entry JoinExecutor Workflow.Inputs initialization - #4335

Merged
Evan Mattson (moonbox3) merged 7 commits into
microsoft:mainfrom
moonbox3:agent/fix-3948-1
Mar 3, 2026
Merged

Python: Add regression tests for Entry JoinExecutor Workflow.Inputs initialization#4335
Evan Mattson (moonbox3) merged 7 commits into
microsoft:mainfrom
moonbox3:agent/fix-3948-1

Conversation

@moonbox3

@moonbox3 Evan Mattson (moonbox3) commented Feb 27, 2026

Copy link
Copy Markdown
Contributor

Motivation and Context

Note: the original bug is already fixed in main. This PR is adding more tests around it.

When workflow.run() is called with a dict or string input, the Entry node (JoinExecutor with kind: 'Entry') must call _ensure_state_initialized to populate Workflow.Inputs. Without this, expressions like =inputs.age resolve to blank, causing conditions like =Local.age < 13 to always evaluate as true (blank is treated as 0), silently routing all inputs to the wrong branch.

Fixes #3948

Description

The root cause is that the Entry JoinExecutor was not initializing Workflow.Inputs before the workflow's action nodes began executing, leaving input-referencing expressions with no data to resolve. This PR adds two regression tests that directly exercise the broken path: one passing a dict input and asserting the correct conditional branch is taken for both child and adult ages, and one passing a string input and asserting it is accessible via inputs.input. These tests lock in the correct behavior and will catch any future regression in Entry node state initialization.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

Note: PR autogenerated by moonbox3's agent

…initializes Workflow.Inputs

Add tests verifying that when workflow.run() is called with a dict or string
input, the Entry node (JoinExecutor with kind: 'Entry') correctly initializes
Workflow.Inputs via _ensure_state_initialized so that:
- Expressions like =inputs.age resolve to the correct value
- Conditions like =Local.age < 13 evaluate based on actual input (not blank/0)
- String inputs populate both inputs.input and System.LastMessage.Text

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 27, 2026 00:44

@moonbox3 Evan Mattson (moonbox3) left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Automated Code Review

Reviewers: 3 | Confidence: 98%

✓ Correctness

This diff only reformats three assert statements by inlining their f-string failure messages, removing the parenthesized multi-line form. The change is purely cosmetic and functionally equivalent — Python's assert statement accepts the message expression directly. No logic, correctness, or behavior is altered.

✓ Security Reliability

This diff only reformats assert statement message arguments from parenthesized multi-line strings to inline f-strings. There are no security or reliability concerns introduced — the changes are purely cosmetic and do not affect logic, resource handling, or trust boundaries.

✓ Test Coverage

The diff is a pure formatting change — it consolidates multi-line assert failure messages onto single lines. No logic, behaviour, or test coverage is added, removed, or altered. The assertions themselves remain semantically identical, and no new code paths are introduced. From a test-coverage perspective there is nothing to flag.


Automated review by moonbox3's agents

@markwallace-microsoft

Mark Wallace (markwallace-microsoft) commented Feb 27, 2026

Copy link
Copy Markdown
Contributor

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
TOTAL22253275787% 
report-only-changed-files is enabled. No files were changed during this commit :)

Python Unit Test Overview

Tests Skipped Failures Errors Time
4727 247 💤 0 ❌ 0 🔥 1m 17s ⏱️

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds regression coverage to ensure declarative workflows correctly initialize Workflow.Inputs at the Entry node so PowerFx expressions referencing inputs.* behave correctly when workflow.run() is invoked with dict or string inputs (fixes #3948 regression risk).

Changes:

  • Add a regression test verifying dict inputs populate inputs.age so an If condition routes to the correct branch.
  • Add a regression test verifying string inputs populate inputs.input so the value is accessible in expressions.

Comment thread python/packages/declarative/tests/test_workflow_factory.py
@moonbox3
Evan Mattson (moonbox3) requested a review from a team as a code owner February 27, 2026 01:55
@moonbox3
Evan Mattson (moonbox3) removed the request for review from a team February 27, 2026 02:18
Evan Mattson (moonbox3) and others added 2 commits March 3, 2026 15:52
Moving yield inside `with _framework_event_origin()` blocks in the
async generator causes ContextVar token reset failures on Python 3.12
Windows. The token stays un-reset while the generator is suspended,
and async generator finalization in a different contextvars.Context
triggers ValueError, corrupting OpenTelemetry span state and causing
test_span_creation_and_attributes to see leaked spans.

Keep yields outside the context manager blocks to ensure tokens are
reset immediately before the generator suspends.
@moonbox3
Evan Mattson (moonbox3) added this pull request to the merge queue Mar 3, 2026
Merged via the queue into microsoft:main with commit 2e93193 Mar 3, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: DeclarativeWorkflowBuilder - Entry JoinExecutor does not initialize Workflow.Inputs

5 participants