Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cloudfront returns a 502 error when page or post is created/updated in Wordpress in version 6.1.4 #106

Open
AndrewReid-Journey opened this issue Dec 1, 2022 · 3 comments

Comments

@AndrewReid-Journey
Copy link

AndrewReid-Journey commented Dec 1, 2022

Hello,

It looks like in version 6.1.4, when a new post is made or page updated, the request that we are sending to Cloudfront to clear the cache is being reported as malformed and results in 502. The below is an extract from the php logs for when I make a post for a new page.

127.0.0.1 - journey 01/Dec/2022:12:09:31 +0000 "POST /index.php" 200
127.0.0.1 - journey 01/Dec/2022:12:09:35 +0000 "POST /wp/wp-admin/admin-ajax.php" 200
127.0.0.1 - journey 01/Dec/2022:12:09:35 +0000 "POST /wp/wp-admin/admin-ajax.php" 200
127.0.0.1 - journey 01/Dec/2022:12:09:39 +0000 "POST /wp/wp-admin/admin-ajax.php" 200
127.0.0.1 - journey 01/Dec/2022:12:09:39 +0000 "POST /wp/wp-admin/admin-ajax.php" 200
127.0.0.1 - journey 01/Dec/2022:12:09:43 +0000 "POST /wp/wp-admin/admin-ajax.php" 200
NOTICE: PHP message: exception 'Aws\CloudFront\Exception\CloudFrontException' with message 'Error executing "CreateInvalidation" on "https://cloudfront.amazonaws.com/2020-05-31/distribution/<REDACTED_CLOUDFRONT_DISTRO>/invalidation"; AWS HTTP error: Client error: `POST https://cloudfront.amazonaws.com/2020-05-31/distribution/<REDACTED_CLOUDFRONT_DISTRO>/invalidation` resulted in a `400 Bad Request` response:
<?xml version="1.0"?>
<ErrorResponse xmlns="http://cloudfront.amazonaws.com/doc/2020-05-31/"><Error><Type>Sender</Type>< (truncated...)
 InvalidArgument (client): Your request contains one or more invalid invalidation paths. - <?xml version="1.0"?>
<ErrorResponse xmlns="http://cloudfront.amazonaws.com/doc/2020-05-31/"><Error><Type>Sender</Type><Code>InvalidArgument</Code><Message>Your request contains one or more invalid invalidation paths.</Message></Error><RequestId>38f205fa-a2d6-48f0-a1fd-c843bc8b813e</RequestId></ErrorResponse>'
GuzzleHttp\Exception\ClientException: Client error: `POST https://cloudfront.amazonaws.com/2020-05-31/distribution/<REDACTED_CLOUDFRONT_DISTRO>/invalidation` resulted in a `400 Bad Request` response:
<?xml version="1.0"?>
<ErrorResponse xmlns="http://cloudfront.amazonaws.com/doc/2020-05-31/"><Error><Type>Sender</Type>< (truncated...)
 in phar:///var/www/html/wp-content/plugins/c3-cloudfront-clear-cache/libs/aws.phar/GuzzleHttp/Exception/RequestException.php:113
Stack trace:
#0 phar:///var/www/html/wp-content/plugins/c3-cloudfront-clear-cache/libs/aws.phar/GuzzleHttp/Middleware.php(65): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response))
#1 phar:///var/www/html/wp-content/plugins/c3-cloudfront-clear-cache/libs/aws.phar/GuzzleHttp/Promise/Promise.php(204): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Response))
#2 phar:///var/www/html/wp-content/plugins/c3-cloudfront-clear-cache/libs/aws.phar/GuzzleHttp/Promise/Promise.php(153): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), NULL)
#3 phar:///var/www/html/wp-content/plugins/c3-cloudfront-clear-cache/libs/aws.phar/GuzzleHttp/Promise/TaskQueue.php(48): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}()
#4 phar:///var/www/html/wp-content/plugins/c3-cloudfront-clear-cache/libs/aws.phar/GuzzleHttp/Handler/CurlMultiHandler.php(118): GuzzleHttp\Promise\TaskQueue->run()
#5 phar:///var/www/html/wp-content/plugins/c3-cloudfront-clear-cache/libs/aws.phar/GuzzleHttp/Handler/CurlMultiHandler.php(145): GuzzleHttp\Handler\CurlMultiHandler->tick()
#6 phar:///var/www/html/wp-content/plugins/c3-cloudfront-clear-cache/libs/aws.phar/GuzzleHttp/Promise/Promise.php(248): GuzzleHttp\Handler\CurlMultiHandler->execute(true)
#7 phar:///var/www/html/wp-content/plugins/c3-cloudfront-clear-cache/libs/aws.phar/GuzzleHttp/Promise/Promise.php(224): GuzzleHttp\Promise\Promise->invokeWaitFn()
#8 phar:///var/www/html/wp-content/plugins/c3-cloudfront-clear-cache/libs/aws.phar/GuzzleHttp/Promise/Promise.php(269): GuzzleHttp\Promise\Promise->waitIfPending()
#9 phar:///var/www/html/wp-content/plugins/c3-cloudfront-clear-cache/libs/aws.phar/GuzzleHttp/Promise/Promise.php(226): GuzzleHttp\Promise\Promise->invokeWaitList()
#10 phar:///var/www/html/wp-content/plugins/c3-cloudfront-clear-cache/libs/aws.phar/GuzzleHttp/Promise/Promise.php(269): GuzzleHttp\Promise\Promise->waitIfPending()
#11 phar:///var/www/html/wp-content/plugins/c3-cloudfront-clear-cache/libs/aws.phar/GuzzleHttp/Promise/Promise.php(226): GuzzleHttp\Promise\Promise->invokeWaitList()
#12 phar:///var/www/html/wp-content/plugins/c3-cloudfront-clear-cache/libs/aws.phar/GuzzleHttp/Promise/Promise.php(62): GuzzleHttp\Promise\Promise->waitIfPending()
#13 phar:///var/www/html/wp-content/plugins/c3-cloudfront-clear-cache/libs/aws.phar/Aws/AwsClientTrait.php(58): GuzzleHttp\Promise\Promise->wait()
#14 phar:///var/www/html/wp-content/plugins/c3-cloudfront-clear-cache/libs/aws.phar/Aws/AwsClientTrait.php(86): Aws\AwsClient->execute(Object(Aws\Command))
#15 /var/www/html/wp-content/plugins/c3-cloudfront-clear-cache/classes/AWS/CloudFront_Service.php(210): Aws\AwsClient->__call('createInvalidat...', Array)
#16 /var/www/html/wp-content/plugins/c3-cloudfront-clear-cache/classes/Invalidation_Service.php(250): C3_CloudFront_Cache_Controller\AWS\CloudFront_Service->create_invalidation(Array)
#17 /var/www/html/wp-content/plugins/c3-cloudfront-clear-cache/classes/Invalidation_Service.php(299): C3_CloudFront_Cache_Controller\Invalidation_Service->invalidate_by_query(Array, false)
#18 /var/www/html/wp-content/plugins/c3-cloudfront-clear-cache/classes/Invalidation_Service.php(222): C3_CloudFront_Cache_Controller\Invalidation_Service->invalidate_post_cache(Object(WP_Post))
#19 /var/www/html/wp/wp-includes/class-wp-hook.php(308): C3_CloudFront_Cache_Controller\Invalidation_Service->invalidate_by_changing_post_status('publish', 'draft', Object(WP_Post))
#20 /var/www/html/wp/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters(NULL, Array)
#21 /var/www/html/wp/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#22 /var/www/html/wp/wp-includes/post.php(5347): do_action('transition_post...', 'publish', 'draft', Object(WP_Post))
#23 /var/www/html/wp/wp-includes/post.php(4607): wp_transition_post_status('publish', 'draft', Object(WP_Post))
#24 /var/www/html/wp/wp-includes/post.php(4819): wp_insert_post(Array, false, true)
#25 /var/www/html/wp/wp-admin/includes/post.php(426): wp_update_post(Array)
#26 /var/www/html/wp/wp-admin/post.php(227): edit_post()
#27 {main}
Next Aws\CloudFront\Exception\CloudFrontException: Error executing "CreateInvalidation" on "https://cloudfront.amazonaws.com/2020-05-31/distribution/<REDACTED_CLOUDFRONT_DISTRO>/invalidation"; AWS HTTP error: Client error: `POST https://cloudfront.amazonaws.com/2020-05-31/distribution/<REDACTED_CLOUDFRONT_DISTRO>/invalidation` resulted in a `400 Bad Request` response:
<?xml version="1.0"?>
<ErrorResponse xmlns="http://cloudfront.amazonaws.com/doc/2020-05-31/"><Error><Type>Sender</Type>< (truncated...)
 InvalidArgument (client): Your request contains one or more invalid invalidation paths. - <?xml version="1.0"?>
<ErrorResponse xmlns="http://cloudfront.amazonaws.com/doc/2020-05-31/"><Error><Type>Sender</Type><Code>InvalidArgument</Code><Message>Your request contains one or more invalid invalidation paths.</Message></Error><RequestId>38f205fa-a2d6-48f0-a1fd-c843bc8b813e</RequestId></ErrorResponse> in phar:///var/www/html/wp-content/plugins/c3-cloudfront-clear-cache/libs/aws.phar/Aws/WrappedHttpHandler.php:195
Stack trace:
#0 phar:///var/www/html/wp-content/plugins/c3-cloudfront-clear-cache/libs/aws.phar/Aws/WrappedHttpHandler.php(97): Aws\WrappedHttpHandler->parseError(Array, Object(GuzzleHttp\Psr7\Request), Object(Aws\Command), Array)
#1 phar:///var/www/html/wp-content/plugins/c3-cloudfront-clear-cache/libs/aws.phar/GuzzleHttp/Promise/Promise.php(204): Aws\WrappedHttpHandler->Aws\{closure}(Array)
#2 phar:///var/www/html/wp-content/plugins/c3-cloudfront-clear-cache/libs/aws.phar/GuzzleHttp/Promise/Promise.php(169): GuzzleHttp\Promise\Promise::callHandler(2, Array, NULL)
#3 phar:///var/www/html/wp-content/plugins/c3-cloudfront-clear-cache/libs/aws.phar/GuzzleHttp/Promise/RejectedPromise.php(42): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}(Array)
#4 phar:///var/www/html/wp-content/plugins/c3-cloudfront-clear-cache/libs/aws.phar/GuzzleHttp/Promise/TaskQueue.php(48): GuzzleHttp\Promise\RejectedPromise::GuzzleHttp\Promise\{closure}()
#5 phar:///var/www/html/wp-content/plugins/c3-cloudfront-clear-cache/libs/aws.phar/GuzzleHttp/Handler/CurlMultiHandler.php(118): GuzzleHttp\Promise\TaskQueue->run()
#6 phar:///var/www/html/wp-content/plugins/c3-cloudfront-clear-cache/libs/aws.phar/GuzzleHttp/Handler/CurlMultiHandler.php(145): GuzzleHttp\Handler\CurlMultiHandler->tick()
#7 phar:///var/www/html/wp-content/plugins/c3-cloudfront-clear-cache/libs/aws.phar/GuzzleHttp/Promise/Promise.php(248): GuzzleHttp\Handler\CurlMultiHandler->execute(true)
#8 phar:///var/www/html/wp-content/plugins/c3-cloudfront-clear-cache/libs/aws.phar/GuzzleHttp/Promise/Promise.php(224): GuzzleHttp\Promise\Promise->invokeWaitFn()
#9 phar:///var/www/html/wp-content/plugins

If the plugin is disabled in Wordpress, I do not have this problem and the page is updated successfully. If I roll back a website to a version from last week which has version 6.1.3 baked into the docker image that we use, I also do not have the problem. I've been able to reproduce this on a couple of sites where the plugin is used. We use PHP version 7.4.

As a side note, it looks like the tag of 6.1.3 has gone missing from this repo. Was that intentional?

@vincefrog
Copy link

Hi,
We are experiencing the same error on WP 6.0 and C3 Cloudfront Cache Controller V6.1.4,
Can you please assist ?

@kevGalway
Copy link

Same issue here

@Benedikt0x4C
Copy link

The exact same issue is still happening with the latest plugin version (6.1.5) and WordPress 6.6. That makes the plugin unusable, unfortunately.

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

No branches or pull requests

4 participants