Description
GetTask and SetTask only accept an array (or null) input, which is merged over their options. Any other non-empty input (typically a string output by a previous task) is not reported: AbstractCacheTask::getMergedOptions() passes it to array_merge() and the task fails with a \TypeError unrelated to the task.
Reproduction
demo.cache.get_invalid_input in process-bundle-demo:
clever_age_process:
configurations:
demo.cache.get_invalid_input:
tasks:
sku:
service: '@CleverAge\ProcessBundle\Task\ConstantOutputTask'
options:
output: 'key1'
outputs: [get]
get:
service: '@CleverAge\CacheProcessBundle\Task\GetTask'
options:
adapter: 'memory'
key: '' # Overridden by the input
outputs: [debug]
debug:
service: '@CleverAge\ProcessBundle\Task\Debug\DebugTask'
$ bin/console cleverage:process:execute demo.cache.get_invalid_input
In AbstractCacheTask.php line 52:
array_merge(): Argument #2 must be of type array, string given
Same with SetTask.
Expected: an explicit \UnexpectedValueException, e.g. GetTask expects an array or null input, string given.
Tested on main (f5e8bb2), cleverage/process-bundle 5.1, PHP 8.5, Symfony 7.4.
Proposed fix
Check the input type in AbstractCacheTask::getMergedOptions() and throw an \UnexpectedValueException giving the task and the received type. Update the "Accepted inputs" section of get_task.md and set_task.md.
Requirements
Breaking changes
None: these inputs already make the task fail, only the exception changes.
Description
GetTaskandSetTaskonly accept anarray(ornull) input, which is merged over their options. Any other non-empty input (typically astringoutput by a previous task) is not reported:AbstractCacheTask::getMergedOptions()passes it toarray_merge()and the task fails with a\TypeErrorunrelated to the task.Reproduction
demo.cache.get_invalid_inputin process-bundle-demo:Same with
SetTask.Expected: an explicit
\UnexpectedValueException, e.g.GetTask expects an array or null input, string given.Tested on
main(f5e8bb2), cleverage/process-bundle 5.1, PHP 8.5, Symfony 7.4.Proposed fix
Check the input type in
AbstractCacheTask::getMergedOptions()and throw an\UnexpectedValueExceptiongiving the task and the received type. Update the "Accepted inputs" section ofget_task.mdandset_task.md.Requirements
Breaking changes
None: these inputs already make the task fail, only the exception changes.