Commit 6fd28a8a316 for woocommerce
commit 6fd28a8a316703676a187cc782e61f6d03416327
Author: Viktor Szépe <viktor@szepe.net>
Date: Tue Sep 8 13:58:57 2026 +0200
Change error status from 400 to 429 for rate limits (#68066)
* Change error status from 400 to 429 for rate limits
* Change expected status code from 400 to 429
* Add changelog entry for Store API rate limit status
---------
Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
diff --git a/plugins/woocommerce/changelog/fix-store-api-rate-limit-status b/plugins/woocommerce/changelog/fix-store-api-rate-limit-status
new file mode 100644
index 00000000000..ba79cc8893c
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-store-api-rate-limit-status
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Return HTTP 429 instead of 400 when Store API requests exceed the rate limit.
diff --git a/plugins/woocommerce/src/StoreApi/Authentication.php b/plugins/woocommerce/src/StoreApi/Authentication.php
index d5d0ca11a7f..8fca2d86862 100644
--- a/plugins/woocommerce/src/StoreApi/Authentication.php
+++ b/plugins/woocommerce/src/StoreApi/Authentication.php
@@ -249,7 +249,7 @@ class Authentication {
'Too many requests. Please wait %d seconds before trying again.',
$retry
),
- array( 'status' => 400 )
+ array( 'status' => 429 )
);
}
diff --git a/plugins/woocommerce/tests/php/src/Blocks/StoreApi/RateLimitsTests.php b/plugins/woocommerce/tests/php/src/Blocks/StoreApi/RateLimitsTests.php
index 38c041f40e7..d901334bfbf 100644
--- a/plugins/woocommerce/tests/php/src/Blocks/StoreApi/RateLimitsTests.php
+++ b/plugins/woocommerce/tests/php/src/Blocks/StoreApi/RateLimitsTests.php
@@ -89,7 +89,7 @@ class RateLimitsTests extends WP_Test_REST_TestCase {
$body = json_decode( $spy_rest_server->sent_body );
$this->assertEquals( JSON_ERROR_NONE, json_last_error() );
- $this->assertEquals( 400, $body->data->status );
+ $this->assertEquals( 429, $body->data->status );
$this->assertEquals( $rate_limiting_options->limit, $spy_rest_server->sent_headers['RateLimit-Limit'] );
$this->assertIsInt( $spy_rest_server->sent_headers['RateLimit-Reset'] );