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

Abierto Apto para principiantes
#177 0 comentarios 0 reacciones 0 asignados Ver en GitHub

@florian-burelli ya está trabajando en esto.

Desde el 7/10/2026.

  • #181 de @florian-burelli — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
88/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python
Área
testing

Línea de trabajo

Comienza en src/data_factory_testing_framework/_pythonnet/data_factory_testing_framework_expressions_evaluator.py#L53 y ejecuta después la reproducción proporcionada de @range(0, 3). Se considera terminado cuando ForEach produce los resultados de Append_Item 0, 1 y 2, mientras que los elementos de iteración no establecidos siguen generando StateIterationItemNotSetError; comprueba las demás pruebas de truthiness de iteration_item indicadas.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Python
Estrellas
135
Forks
44
Merge medio
6 d 20 h
PR fusionados (30 d)
2

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

  • Sin Dockerfile ni archivo de Docker Compose
  • Sin plantilla de pull request
  • Sin guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de microsoft/data-factory-testing-framework

Todos los issues de microsoft/data-factory-testing-framework

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.