IfCondition evaluates the expressions of the branch not taken (case-sensitive "activities" check)
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 84/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- python
- Lĩnh vực
- devtools, testing-qa
Hướng nghiên cứu
Bắt đầu trong src/data_factory_testing_framework/models/activities/_activity.py tại trình duyệt biểu thức quanh các dòng 89 và 101, sau đó tái hiện ví dụ IfCondition được cung cấp. Đảm bảo các khóa danh sách activity lồng nhau được bỏ qua bất kể chữ hoa chữ thường, và xác minh rằng chỉ Set_Today được đánh giá khi điều kiện là true mà không đánh giá biểu thức của nhánh false.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Python
- Star
- 135
- Fork
- 44
- Merge trung bình
- 6 ngày 20 giờ
- Pull request đã merge (30 ngày)
- 2
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của microsoft/data-factory-testing-framework
-
A new ExpressionRuntime (Lark grammar compile) per evaluated expression makes evaluation ~5x slowerCó thể đã có người làm @florian-burelli đã nhận 31 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
-
item() equal to 0 raises StateIterationItemNotSetError (falsy item treated as unset)Có thể đã có người làm @florian-burelli đã nhận 31 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
-
DataFactoryTestingFrameworkExpressionsEvaluator adds status property even if None is set.Có thể đã có người làm @LeonardHd đã nhận 466 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
Tất cả issue của microsoft/data-factory-testing-framework
Issue tương tự
-
integration: logger
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
home-assistant/core#191147 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation p4
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
MillenniumDawn/focus-tree-creation-tool#417 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
CharlesP44/Beem_Energy#96 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
rheeloaded/paperpull#153 ·
Maintainer thường phản hồi trong vòng 1 ngày