Skip to content

An exception thrown by initialize() does not abort the process: upstream tasks run, or the process succeeds #222

Closed

Description

@njoubert-cleverage

Description

An exception thrown by initialize() (for instance an invalid option of a configurable task) is logged as critical and flags the task as stopped, but it does not abort the process:

  • the tasks upstream of the misconfigured task are executed (with their side effects: files written, database updates, API calls...), then the process fails when the misconfigured task is first reached;
  • if the misconfigured task is never reached (filtered branch...), the process ends with "executed successfully", in spite of the critical log. If the task is flushable, it fails anyway during the flush: the result depends on the task type.

Initialization errors are configuration errors, they do not depend on the data: the process should fail before executing any task.

Reproduction

clever_age_process:
    configurations:
        arb.init_failure_late:
            tasks:
                entry:
                    service: '@CleverAge\ProcessBundle\Task\ConstantOutputTask'
                    options: { output: 'x' }
                    outputs: [ log ]
                log:
                    service: '@CleverAge\ProcessBundle\Task\Debug\DebugTask'
                    outputs: [ bad ]
                bad:
                    service: '@CleverAge\ProcessBundle\Task\CounterTask'
                    options: { flush_every: 'not-an-int' }
        arb.init_failure_unreached:
            tasks:
                entry:
                    service: '@CleverAge\ProcessBundle\Task\ConstantOutputTask'
                    options: { output: 'x' }
                    outputs: [ filter ]
                filter:
                    service: '@CleverAge\ProcessBundle\Task\FilterTask'
                    options: { match: { '': 'never' } }
                    outputs: [ bad ]
                bad:
                    service: '@CleverAge\ProcessBundle\Task\FilterTask'
                    options: { not_an_option: true }
$ bin/console cleverage:process:execute arb.init_failure_late
CRITICAL [cleverage_process_task] The option "flush_every" with value "not-an-int" is expected to be of type "int", but is of type "string".
"x"                                             <- upstream task executed
... Process arb.init_failure_late has failed during process bad ...

$ bin/console cleverage:process:execute arb.init_failure_unreached
CRITICAL [cleverage_process_task] The option "not_an_option" does not exist. Defined options are: "empty", "match", ...
Process 'arb.init_failure_unreached' executed successfully

Tested on main (1d202a2), PHP 8.5, Symfony 7.4.

Cause

ProcessManager::initialize() catches the exception, logs it and calls $state->stop($e) without rethrowing it.

Proposed fix

Failing at initialization changes the behaviour of existing processes, so it is done in two steps:

  • v5 (this issue): keep the current behaviour, and trigger an E_USER_DEPRECATED error for each initialization failure: The initialization of the task "<task>" of the process "<process>" has failed with message "<message>". Going on with the process after an initialization failure is deprecated since v5: in v6.0, the process will fail before executing any task. Document the deprecation (02-task_types.md, 03-custom_tasks.md, 04-advanced_workflow.md), add tests.
  • v6.0: rethrow the initialization exception (wrapped with the task and process codes), before any task is executed.

Requirements

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

Breaking changes

None in v5 (deprecation only). In v6.0, a process with a misconfigured task will fail before executing any task, even if this task is never reached.

Activity

  1. added a commit that references this issue on Sep 28, 2026
  2. added a commit that references this issue on Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions