Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

item() equal to 0 raises StateIterationItemNotSetError (falsy item treated as unset)

Open Beginner friendly
#177 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
88/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
testing

Research direction

Start at src/data_factory_testing_framework/_pythonnet/data_factory_testing_framework_expressions_evaluator.py#L53, then run the supplied @range(0, 3) reproduction. Done means the ForEach produces Append_Item results 0, 1, and 2, while unset iteration items still raise StateIterationItemNotSetError; check other iteration_item truthiness tests as noted.

Written by the indexing model from the issue text.

Description

Inside a ForEach, an item() whose value is 0 raises StateIterationItemNotSetError, as if no item were set. @range(0, n) therefore fails on its first iteration.

Environment: data-factory-testing-framework 1.4.2 (also present on main at 11b9f27), Python 3.12.13, .NET 10.0.12, Linux.

Repro

import json, tempfile
from pathlib import Path

from data_factory_testing_framework import TestFramework, TestFrameworkType

pipeline = {
    "name": "item_zero",
    "properties": {
        "variables": {"items": {"type": "Array"}},
        "activities": [
            {
                "name": "Each_Day",
                "type": "ForEach",
                "dependsOn": [],
                "typeProperties": {
                    "items": {"value": "@range(0, 3)", "type": "Expression"},
                    "activities": [
                        {
                            "name": "Append_Item",
                            "type": "AppendVariable",
                            "dependsOn": [],
                            "typeProperties": {
                                "variableName": "items",
                                "value": {"value": "@item()", "type": "Expression"},
                            },
                        }
                    ],
                },
            }
        ],
    },
}

root = Path(tempfile.mkdtemp())
(root / "pipeline").mkdir()
(root / "pipeline" / "item_zero.json").write_text(json.dumps(pipeline))

framework = TestFramework(framework_type=TestFrameworkType.DataFactory, root_folder_path=str(root))
for activity in framework.evaluate_pipeline(framework.get_pipeline_by_name("item_zero"), []):
    print(activity.name, activity.type_properties["value"].result)  # expected: 0, 1, 2

Expected: Append_Item 0, Append_Item 1, Append_Item 2.

Actual:

StateIterationItemNotSetError: Iteration item not set.

Cause

data_factory_testing_framework_expressions_evaluator.py#L53 tests the item for truthiness:

state_iter_item_json = json.dumps(state.iteration_item) if state.iteration_item else None

so any falsy item (0, and by the same line "", false, [], {}) is sent to the evaluator as "no item". Verified with 0.

Suggested fix: if state.iteration_item is not None else None. The same check probably matters wherever iteration_item is tested for truthiness.

Dominant language
Python
Stars
135
Forks
43
Avg merge
1h 14m
Merged PRs (30d)
1

Getting set up

Open in Codespaces

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/data-factory-testing-framework

All issues in microsoft/data-factory-testing-framework

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.