IfCondition evaluates the expressions of the branch not taken (case-sensitive "activities" check)
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 84/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- python
- 領域
- devtools, testing-qa
調査の方向性
src/data_factory_testing_framework/models/activities/_activity.py の89行目と101行目付近にある式ウォーカーから始め、提供された IfCondition の例を再現してください。ネストされたアクティビティリストのキーが大文字小文字に関係なくスキップされることを確認し、条件が true の場合に false ブランチの式を評価せず、Set_Today だけが評価されることを検証してください。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- Python
- スター
- 135
- フォーク
- 44
- 平均マージ
- 1時間 14分
- マージ済み PR(30日)
- 1
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
microsoft/data-factory-testing-framework のほかの issue
-
A new ExpressionRuntime (Lark grammar compile) per evaluated expression makes evaluation ~5x slower対応中かも @florian-burelli が 17 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
-
item() equal to 0 raises StateIterationItemNotSetError (falsy item treated as unset)対応中かも @florian-burelli が 17 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
DataFactoryTestingFrameworkExpressionsEvaluator adds status property even if None is set.対応中かも @LeonardHd が 452 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
microsoft/data-factory-testing-framework の issue をすべて見る
似ている issue
-
Project submission:オープン
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
slavakurilyak/awesome-ai-agents#845 ·
メンテナーはふだん 1 日以内に返信
-
tests: pin that the atomic writers in utils/paths.py stage the temporary file in the target's directory対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンdifficulty:2 enhancement good first issue
難易度 1/5 1〜3時間 初心者へのやさしさ 92/100
MakazhanAlpamys/Soup#2178 ·
メンテナーはふだん 1 日以内に返信
-
[BUG] dcg.waggr permutation p-values are folded twice, so near-zero scores get the smallest p-valuesオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
scverse/rapids-singlecell#854 ·
メンテナーはふだん 1 日以内に返信
-
Slang input: int8_t4_packed and uint8_t4_packed are copied into CrossGL対応中かも @ninglinLiu が 1 日前に担当しました。 オープンarea:frontend backend:slang bug direction:input
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
random_elements(unique=True) on an OrderedDict: ZeroDivisionError once only zero weights remain, AssertionError with use_weighting=False対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 13 日以内に返信