When the Mailchimp API returns a 500 error it causes MailchimpGuzzleHttpClient to throw a 500 error. This causes any page the mailchimp form shows up on to also throw a 500 error.

Uncaught PHP Exception Mailchimp\\MailchimpAPIException: "500: Internal Server Error - A deep, internal error has occurred during the processing of your request. Please contact support." at /var/www/html/site/web/modules/contrib/mailchimp/lib/mailchimp-api-php/src/http/MailchimpGuzzleHttpClient.php line 64

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

NickDJM created an issue. See original summary.

NickDJM’s picture

Not a great solution, but for now I have commented out the throw new MailchimpAPIException after its already caught the initial exception from the API itself.

firewaller’s picture

Status: Active » Needs work

This issue is happening is Drupal 7 as well, taking down the site when Mailchimp API is having issues. The above patch works, but does not seem like a longterm solution.

lindsay.wils’s picture

Also getting a similar issue. We have a mailchimp form sitting in the footer of the site and when the exception is thrown no page works and the error is shown, essentially taking down the site. Seemed to be only when logged in for some reason. A cache clear fixed the issue. temporarily.

The website encountered an unexpected error. Please try again later.Mailchimp\MailchimpAPIException: 404: Resource Not Found - The requested resource could not be found. in Mailchimp\http\MailchimpGuzzleHttpClient->handleRequest() (line 64 of /srv/bindings/c8c607c098304952a3f6fabf2cfaac8b/code/vendor/thinkshout/mailchimp-api-php/src/http/MailchimpGuzzleHttpClient.php).

GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object) (Line: 203)
GuzzleHttp\Promise\Promise::callHandler(1, Object, Array) (Line: 156)
GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}() (Line: 47)
GuzzleHttp\Promise\TaskQueue->run(1) (Line: 246)
GuzzleHttp\Promise\Promise->invokeWaitFn() (Line: 223)
GuzzleHttp\Promise\Promise->waitIfPending() (Line: 267)
GuzzleHttp\Promise\Promise->invokeWaitList() (Line: 225)
GuzzleHttp\Promise\Promise->waitIfPending() (Line: 62)
GuzzleHttp\Promise\Promise->wait() (Line: 131)
GuzzleHttp\Client->request('GET', 'https://us7.api.mailchimp.com/3.0/lists/c8e802de23/interest-categories/7099265e70/interests', Array) (Line: 50)
Mailchimp\http\MailchimpGuzzleHttpClient->handleRequest('GET', 'https://us7.api.mailchimp.com/3.0/lists/c8e802de23/interest-categories/7099265e70/interests', Array, Array, ) (Line: 289)
Mailchimp\Mailchimp->request('GET', '/lists/c8e802de23/interest-categories/7099265e70/interests', Array, Array) (Line: 91)
Mailchimp\MailchimpLists->getInterests('c8e802de23', '7099265e70', Array) (Line: 1069)
mailchimp_interest_groups_form_elements(Object) (Line: 112)
Drupal\mailchimp_signup\Form\MailchimpSignupPageForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 519)
Drupal\Core\Form\FormBuilder->retrieveForm('mailchimp_signup_subscribe_block_red_jacket_resorts_special_offer_form', Object) (Line: 276)
Drupal\Core\Form\FormBuilder->buildForm('mailchimp_signup_subscribe_block_red_jacket_resorts_special_offer_form', Object) (Line: 217)
Drupal\Core\Form\FormBuilder->getForm(Object) (Line: 35)
Drupal\mailchimp_signup\Plugin\Block\MailchimpSignupSubscribeBlock->build() (Line: 163)
Drupal\block\BlockViewBuilder::preRender(Array)
call_user_func('Drupal\block\BlockViewBuilder::preRender', Array) (Line: 378)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array) (Line: 501)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 89)
__TwigTemplate_52eb7eb2887135c7090146659f806f50b44658633a39475d573c742a6501fa2a->doDisplay(Array, Array) (Line: 427)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 398)
Twig\Template->display(Array) (Line: 85)
__TwigTemplate_4b5af4ea3e1336e6e1c594e996c3c941f56a1c19a09ff96957c3d34a8a8f11ad->doDisplay(Array, Array) (Line: 427)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 398)
Twig\Template->display(Array, Array) (Line: 60)
__TwigTemplate_009a5c8b18faa6ffbc82805bffebbd12d304beddbb4e9045716a38ba02b8c706->doDisplay(Array, Array) (Line: 427)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 398)
Twig\Template->display(Array) (Line: 406)
Twig\Template->render(Array) (Line: 64)
twig_render_template('themes/custom/origin/templates/layout/page.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('page', Array) (Line: 437)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array) (Line: 501)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 139)
__TwigTemplate_f5e768a863f5ab13adc5dec821a17d1904f2f555dd21b2309f71c762f4521dd3->doDisplay(Array, Array) (Line: 427)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 398)
Twig\Template->display(Array) (Line: 406)
Twig\Template->render(Array) (Line: 64)
twig_render_template('themes/custom/origin/templates/layout/html.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('html', Array) (Line: 437)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array) (Line: 147)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 148)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object) (Line: 156)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 693)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
NickDJM’s picture

I've done a little more digging into this issue and I found 2 API calls that aren't inside of a try/catch block which seems to be the cause of this issue.

I've changed the patch up to add 2 try/catches to the module file. It looks like it's solving the issue for our website, hopefully others can confirm or expand on the issue.

StijnStroobants’s picture

Status: Needs work » Reviewed & tested by the community

Reviewed the patch and successfully applied.

mshaver’s picture

Assigned: Unassigned » samuel.mortenson

  • NickDJM authored 02a202a on 8.x-1.x
    Issue #3000365 by NickDJM, StijnStroobants: MailchimpGuzzleHttpClient...
samuel.mortenson’s picture

Status: Reviewed & tested by the community » Fixed

This fix makes sense to me, thanks all!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.