Skip to content

#203 - Fix ProcessState::addErrorContextValue() TypeError on empty iterables and PropertySetterTask - #214

Merged
njoubert-cleverage merged 2 commits into
mainfrom
203
Sep 28, 2026
Merged

njoubert-cleverage merged 2 commits into
mainfrom
203

Conversation

@njoubert-cleverage

Copy link
Copy Markdown
Member

Description

Fixes #203.

ProcessState::addErrorContextValue() only accepts string|int|array values. When a task passes any other value (null, bool, float, object), a \TypeError is thrown and the real behaviour or error is lost:

  • Iterable tasks on an empty iterable (ConstantIterableOutputTask, InputIteratorTask, YamlReaderTask with {}/[], SplitJoinLineTask with no line to produce): AbstractIterableOutputTask::execute() always adds iterator_key before checking the iterator. On an empty iterator key() is null, so the process fails instead of skipping the task, as documented.
  • PropertySetterTask: when a value cannot be set, the task adds the value to the error context. If that value is a bool, float, null or object, the TypeError replaces the original exception (e.g. NoSuchPropertyException).

This PR:

  • Widen the $value parameter of ProcessState::addErrorContextValue() to mixed.
  • In AbstractIterableOutputTask::execute(), add iterator_key only when the iterator is valid: an empty iterable then produces no output and the task is skipped.
  • Update the reference documentation (property_setter_task.md, yaml_reader_task.md, split_join_line_task.md, 03-custom_tasks.md), add unit tests.

The new regression tests fail on main and pass with this fix. PHPUnit, PHPStan, PHP-CS-Fixer and Rector pass.

Requirements

  • Documentation updates
    • Reference
    • Cookbooks
    • Changelog
  • Unit tests

Breaking changes

None for callers. Widening a parameter type is backward compatible, except for a subclass of ProcessState overriding addErrorContextValue() with the old signature (it must widen $value to mixed).

🤖 Generated with Claude Code

… value type, so that iterable tasks on an empty iterable are skipped and PropertySetterTask reports the original exception instead of a `TypeError`. Update documentation, add tests.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@njoubert-cleverage njoubert-cleverage changed the title #203 - Fix `ProcessState #203 - Fix ProcessState::addErrorContextValue() TypeError on empty iterables and PropertySetterTask Sep 28, 2026
@njoubert-cleverage
njoubert-cleverage merged commit b59aa59 into main Sep 28, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ProcessState::addErrorContextValue() raises a TypeError that hides the real problem (empty iterables, PropertySetterTask)

1 participant