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

Fix webhooks (route protection and cache invalidation on Unpublish) #93

Merged
merged 4 commits into from
Feb 6, 2023

Conversation

peterjaap
Copy link
Contributor

@peterjaap peterjaap commented Feb 3, 2023

This fixes the Invalid return type 500 error on the webhooks;

Exception #0 (InvalidArgumentException): Invalid return type                                                                                                                                                       
<pre>#1 Magento\Framework\App\Http\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]                                                                              
#2 Magento\Framework\App\Http\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/justbetter/magento2-sentry/Plugin/GlobalExceptionCatcher.php:57]                                           
#3 JustBetter\Sentry\Plugin\GlobalExceptionCatcher->aroundLaunch() called at [vendor/magento/framework/Interception/Interceptor.php:135]                                                                           
#4 Magento\Framework\App\Http\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]                                                        
#5 Magento\Framework\App\Http\Interceptor->___callPlugins() called at [generated/code/Magento/Framework/App/Http/Interceptor.php:23]                                                                               
#6 Magento\Framework\App\Http\Interceptor->launch() called at [vendor/magento/framework/App/Bootstrap.php:264]                                                                                                     
#7 Magento\Framework\App\Bootstrap->run() called at [pub/index.php:30]                                                                                                                                             
</pre> 

You can test this fix by checking out this branch (or applying the patch) and hitting the webhook locally. Create a payload.json:

{
  "secret": "secretgoeshere"
}

Then hit the controller;

curl --insecure -XPOST  -H 'Content-Type: application/json' -d @payload.json https://yourlocalurl.localhost/prismicio/webhook/cache

This should then return {"success":true}.

@peterjaap peterjaap changed the title Fix route protection in Cache controller Fix webhooks (route protection and cache invalidation on Unpublish) Feb 3, 2023
@sanderjongsma
Copy link
Contributor

ah nice, so it was coming from the protectRoute function.

@peterjaap
Copy link
Contributor Author

@sanderjongsma yeah apparently they moved the location of the secret from the POST request to the actual JSON payload.

@sanderjongsma sanderjongsma merged commit 7106291 into main Feb 6, 2023
@peterjaap peterjaap deleted the peterjaap-patch-1 branch February 9, 2023 09:12
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.

2 participants