IfCondition evaluates the expressions of the branch not taken (case-sensitive "activities" check)
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 84/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- python
- Domain
- devtools, testing-qa
Research direction
Start in src/data_factory_testing_framework/models/activities/_activity.py at the expression walker around lines 89 and 101, then reproduce the provided IfCondition example. Ensure nested activity-list keys are skipped regardless of case, and verify that only Set_Today is evaluated when the condition is true without evaluating the false branch expression.
Written by the indexing model from the issue text.
Description
When an IfCondition activity is evaluated, the expressions of both branches are evaluated, not only the branch that is taken. An expression that is only valid on one branch then makes the evaluation fail.
Environment: data-factory-testing-framework 1.4.2 (also present on main at 11b9f27), Python 3.12.13, .NET 10.0.12, Linux.
Repro
A pipeline uses today's date when the date parameter is empty, and formats the given date otherwise:
import json, tempfile
from pathlib import Path
from data_factory_testing_framework import TestFramework, TestFrameworkType
from data_factory_testing_framework.state import RunParameter, RunParameterType
pipeline = {
"name": "if_branch",
"properties": {
"parameters": {"date": {"type": "string"}},
"variables": {"day": {"type": "String"}},
"activities": [
{
"name": "Has_Date",
"type": "IfCondition",
"dependsOn": [],
"typeProperties": {
"expression": {"value": "@empty(pipeline().parameters.date)", "type": "Expression"},
"ifTrueActivities": [
{
"name": "Set_Today",
"type": "SetVariable",
"dependsOn": [],
"typeProperties": {
"variableName": "day",
"value": {"value": "@formatDateTime(utcNow(), 'yyyy-MM-dd')", "type": "Expression"},
},
}
],
"ifFalseActivities": [
{
"name": "Set_Given_Date",
"type": "SetVariable",
"dependsOn": [],
"typeProperties": {
"variableName": "day",
"value": {
"value": "@formatDateTime(pipeline().parameters.date, 'yyyy-MM-dd')",
"type": "Expression",
},
},
}
],
},
}
],
},
}
root = Path(tempfile.mkdtemp())
(root / "pipeline").mkdir()
(root / "pipeline" / "if_branch.json").write_text(json.dumps(pipeline))
framework = TestFramework(framework_type=TestFrameworkType.DataFactory, root_folder_path=str(root))
activities = framework.evaluate_pipeline(
framework.get_pipeline_by_name("if_branch"), [RunParameter(RunParameterType.Pipeline, "date", "")]
)
print(next(activities).name) # expected: Set_Today
Expected: Set_Today (the condition is true, the false branch never runs, as in Data Factory).
Actual:
DataFactoryElementEvaluationError: Error evaluating expression: @formatDateTime(pipeline().parameters.date, 'yyyy-MM-dd')
(In function 'formatDateTime', the value provided for date time string '' was not valid.)
Cause
IfConditionActivity.evaluate calls Activity._evaluate_expressions, which walks type_properties. The nested activities are still there as raw JSON (type_properties["ifFalseActivities"] holds dicts, not the deserialized activities). The walker is meant to skip them, but the check is case-sensitive (_activity.py#L89, #L101):
if "activities" in key:
continue
activities (ForEach, Switch cases) is skipped, but ifTrueActivities, ifFalseActivities and defaultActivities (Switch) are not, so their expressions are evaluated eagerly, in the scope of the container.
Suggested fix: if "activities" in key.lower(): (and the same for attribute_name), or drop the raw nested activity lists from type_properties once they are deserialized.
- Dominant language
- Python
- Stars
- 135
- Forks
- 43
- Avg merge
- 1h 14m
- Merged PRs (30d)
- 1
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- No pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/data-factory-testing-framework
-
A new ExpressionRuntime (Lark grammar compile) per evaluated expression makes evaluation ~5x slowerOpen
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
DataFactoryTestingFrameworkExpressionsEvaluator adds status property even if None is set.Possibly taken @LeonardHd claimed this 432 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
All issues in microsoft/data-factory-testing-framework
Similar issues
-
json_params_matcher fails on falsy top-level JSON primitives (0, False, "")Possibly taken @mayureshsonawane17 claimed this today. OpenWaiting for: Product Owner
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 5 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
bojieli/ai-agent-book#1169 ·
Maintainers usually reply within 1 day
-
priority:low ready-for-dev
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
OpenHands/extensions#738 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
micronaut-projects/micronaut-core#13677 ·
Maintainers usually reply within 1 day