Skip to content

fix(task) #22 #23 GetTask and SetTask reject non-array inputs and validate the option values given by the input - #24

Merged
njoubert-cleverage merged 2 commits into
mainfrom
22
Sep 30, 2026
Merged

njoubert-cleverage merged 2 commits into
mainfrom
22

Conversation

@njoubert-cleverage

Copy link
Copy Markdown
Member

Description

Fixes #22.
Fixes #23.

GetTask and SetTask merged their input over their resolved options with array_merge(): a non-array input triggered an unrelated \TypeError, and the values given by the input (adapter, key, value) were never validated by the options resolver.

  • AbstractCacheTask::getMergedOptions(): throw an \UnexpectedValueException giving the task and the received type on a non-array input (GetTask and SetTask fail with an unrelated TypeError on a non-array input #22); resolve the options merged with the input keys matching a defined option, so the input values are validated and the other input keys stay ignored (GetTask and SetTask do not validate the option values given by the input #23)
  • GetTaskTest, SetTaskTest (new): nominal cases, input overriding the options, non-array input and invalid input value (the last two fail without the fix)
  • get_task.md, set_task.md: update "Accepted inputs", remove the note "The values coming from the input are not validated"; index.md: getMergedOptions() description for custom cache tasks

Checked with process-bundle-demo:

  • demo.cache.get_invalid_input: GetTask expects an array or null input, string given (array_merge(): Argument #2 must be of type array, string given before)
  • demo.cache.set_invalid_input_option: The option "adapter" with value 1 is expected to be of type "string", but is of type "int". (TypeError from AdapterRegistry::getAdapter() before)
  • demo.cache.set_get: unchanged

Both issues are fixed in the same PR because they change the same method.

Requirements

  • Documentation updates
    • Reference
    • Changelog
  • Unit tests

Breaking changes

None for valid inputs. Non-array inputs and invalid input values already made the task fail (or passed an invalid key to the adapter), only the exception changes. A custom task extending AbstractCacheTask now gets resolved options from getMergedOptions(), including the input values of its own options.

🤖 Generated with Claude Code

…idate the option values given by the input

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… for the strict coverage metadata

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.

GetTask and SetTask do not validate the option values given by the input GetTask and SetTask fail with an unrelated TypeError on a non-array input

1 participant