Error outputed upon saving the form of a send mail action: InvalidArgumentException: Cannot set a list with a non-array value. in Drupal\Core\TypedData\Plugin\DataType\ItemList->setValue() (line 59 of core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php).

Steps to reproduce the bug:

  • Create a fresh Drupal 8 install
  • Enable the rules module
  • Navigate to rule configuration page
  • Add a new rule
  • Configure a reaction to: After saving new comment (rules_entity_insert:comment)
  • Add an action
  • Select Send email
  • Configure the action
  • Save the action
  • Observe error

This can be reproduced on https://simplytest.me/ website and on a local environment.

Comments

mgadrat created an issue. See original summary.

roaldumandal’s picture

I can confirm this, its also happening to me, I also tried to add conditions and I am getting this same error message

InvalidArgumentException: Cannot set a list with a non-array value. in Drupal\Core\TypedData\Plugin\DataType\ItemList->setValue() (line 59 of /Users/iamroald/Sites/drupal8/core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php).
jelhan’s picture

Seems to be fixed on current dev (bff3e8d26603def181aaae1cbf059db629b7ed25).

jelhan’s picture

There is another issue still present in dev. If you create a rule containing send mail action it throws on saving the rule (not the action):

InvalidArgumentException: The configuration property expression.actions.actions.0.context_values.to.0 doesn't exist. in Drupal\Core\Config\Schema\ArrayElement->get() (line 74 of core/lib/Drupal/Core/Config/Schema/ArrayElement.php).

Having "test@examples.com" as to and just plain strings as subject and message.

Tested again on clean environment and can't reproduce. I guess I messed up cache while switching versions.

vasyl.kletsko’s picture

I have the same bug in 8.x-3.0-dev version

mgadrat’s picture

I tried to reproduce the bug using the steps I documented in this issue and I did not observe the error.

I tested with 8.x-3.0-alpah2 on https://simplytest.me

I consider it fixed.

vasil kletsko can you try to reproduce the bug and then post your steps?

toddwoof’s picture

In case this is useful to someone: I also couldn't save a send email action. Tried uninstalling, etc. It turns out I initially did something wrong in adding the send email action, and the resulting broken rule doesn't get removed by deleting it. That is, if you delete the rule and create a new one with the same machine name, you will still have a broken rule. Making a new rule with a different machine name worked.

varsharani’s picture

What should I select in "E-mail type" of event type "Send account e-mail"?

DamienMcKenna’s picture

Has anyone tested this with alpha3?

TR’s picture

Yes, I have, and it works for me (see my comment in #2827183-14: System: Send email action fails if $to is a string). But I'm using -dev, not alpha3 ...

I don't think we're all necessarily testing the same thing. Note that when I test, I enter an actual e-mail address in the To: field, and that's what works. But some other reports use the data selector to grab an e-mail value from somewhere, and it's this value that generates the error about converting an array to a string.

As far as the current issue, the instructions to reproduce in the original post simply say "Configure the action" so I have no idea what is being used for the To: value.

There are a number of open issues that all touch on this e-mail problem with the "non-array value" error.
https://www.drupal.org/project/issues/rules?text=email%20array&status=Op...
@fago's comment in #2827183-10: System: Send email action fails if $to is a string implies this is all a side-effect of a bigger issue.

TR’s picture