mailchimp-bundle icon indicating copy to clipboard operation
mailchimp-bundle copied to clipboard

Notice: Undefined index: type

Open PetitGrigri opened this issue 4 years ago • 0 comments

When a subscribed member from a list have been deleted from mailchimp (with "PERMANENTLY DELETE").

If you try to subscribe this member again, the mailchimp api response do not contain the "type" field.

e.g :

[
  "title" => "Forgotten Email Not Subscribed"
  "status" => 400
  "detail" => [email protected] was permanently deleted and cannot be re-imported. The contact must re-subscribe to get back on the list."
  "instance" => "9042d84b-3xc0-4b75-a7c7-f0efbx225328"
]

This causes an error in the "throwMailchimpError" method of the ListRepository" which expects this data :

    private function throwMailchimpError(array $errorResponse)
    {
        $errorArray = json_decode($errorResponse['body'], true);

        if (is_array($errorArray) && array_key_exists('errors', $errorArray)) {
            throw new MailchimpException(
                $errorArray['status'],
                $errorArray['detail'],
                $errorArray['type'],
                $errorArray['title'],
                $errorArray['errors'],
                $errorArray['instance']
            );
        } else {
            throw new MailchimpException(
                $errorArray['status'],
                $errorArray['detail'],
                $errorArray['type'],
                $errorArray['title'],
                null,
                $errorArray['instance']
            );
        }

This error occurs with the version 1.3.1.

PetitGrigri avatar Apr 13 '21 10:04 PetitGrigri