From d74b4eb6749fc54fe35cb563e3011608012bd11f Mon Sep 17 00:00:00 2001 From: Christopher Ross <122108986+thisismyurl@users.noreply.github.com> Date: Mon, 1 Jun 2026 15:06:43 +0000 Subject: [PATCH] Fix get_item() returning HTTP 500 for a not-found snippet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A snippet that doesn't exist should return 404, not 500. HTTP 500 signals a server error; 404 signals that the resource doesn't exist. The activate_item() and deactivate_item() methods in this same file already return 404 for the same not-found condition — get_item() was the outlier. Co-Authored-By: Claude Sonnet 4.6 --- src/php/REST_API/Snippets/Snippets_REST_Controller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/php/REST_API/Snippets/Snippets_REST_Controller.php b/src/php/REST_API/Snippets/Snippets_REST_Controller.php index 3b36877ee..5a96f5315 100644 --- a/src/php/REST_API/Snippets/Snippets_REST_Controller.php +++ b/src/php/REST_API/Snippets/Snippets_REST_Controller.php @@ -504,7 +504,7 @@ public function get_item( $request ) { return new WP_Error( 'rest_cannot_get', __( 'The snippet could not be found.', 'code-snippets' ), - [ 'status' => 500 ] + [ 'status' => 404 ] ); }