Not quite sure where to start debugging, PUT/POST request occasionally without any errors in Magento logs, status code 400. The exact same request later goes through succesfully.
Example failed request:
400 PUT /rest/V1/products/9793/stockItems/1567?stockItem%5Bqty%5D=466&stockItem%5Bis_in_stock%5D=1 HTTP/2.0 varnish
Example successfull request moments later:
200 PUT /rest/V1/products/9793/stockItems/1567?stockItem%5Bqty%5D=466&stockItem%5Bis_in_stock%5D=1 HTTP/1.1 phpfpm
200 PUT /rest/V1/products/9793/stockItems/1567?stockItem%5Bqty%5D=466&stockItem%5Bis_in_stock%5D=1 HTTP/2.0 varnish
Added a log in Magento\CatalogInventory\ModelStockRegistry updateStockItemBySku function, for the failed requests this function is never reached.
Thought it might have to do with Varnish, so I added a bypass, but this had no effect:
if (req.url ~ "^/rest/") {
return (pass);
}
Using Magento 2.4.5-p11, Varnish 6.1.1. Only happens on PUT/POST requests.
Any tips on where to start debugging?
1 Answer 1
Still not entirely sure what caused the issue, after testing different scenarios it turned out Cloudflare was interfering with the requests.
Bypassing the cache and WAF inside Cloudflare had no effect, however lowering the 'security level' did the trick.
There may have been too many requests from one source where Cloudflare flagged and blocked/altered the request, even though the Cloudflare event logs stayed empty.