[wp-trac] [WordPress Trac] #64926: REST API: GET requests fail object/array schema validation when params are JSON-serialized strings

WordPress Trac noreply at wordpress.org
Fri Mar 27 05:36:37 UTC 2026


#64926: REST API: GET requests fail object/array schema validation when params are
JSON-serialized strings
-------------------------+-------------------------------------------------
 Reporter:  dsmy         |       Owner:  (none)
     Type:  defect       |      Status:  new
  (bug)                  |
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  REST API     |     Version:
 Severity:  normal       |  Resolution:
 Keywords:  has-patch    |     Focuses:  javascript, rest-api, php-
                         |  compatibility
-------------------------+-------------------------------------------------

Comment (by liaison):

 Subject: Test Instructions for #64926

 For anyone reviewing, here is a reproducible test case to verify the fix:

 1. Register a Test Endpoint

 PHP
 {{{#!php
 <?php
 register_rest_route( 'my-test/v1', '/schema-test', [
     'methods'  => 'GET',
     'callback' => fn( $req ) => [ 'success' => true, 'data' =>
 $req->get_param( 'config' ) ],
     'args'     => [ 'config' => [ 'type' => 'object' ] ],
 ] );

 }}}

 2. Test Scenarios

 Valid JSON Object: >   GET /wp-json/my-test/v1/schema-
 test?config={"id":123,"active":true}

 Before: 400 Bad Request ("config is not of type object").

 After: 200 OK with data: { id: 123, active: true } (Types preserved).

 Empty Object:
 GET /wp-json/my-test/v1/schema-test?config={}

 Result: 200 OK (Correctly coerced).

 Invalid JSON (Safety):
 GET /wp-json/my-test/v1/schema-test?config={id:123}

 Result: 400 Bad Request (Correctly rejected by core validation because
 decoding failed).

 The PR passes all grunt phpunit tests and adheres to WP Coding Standards
 (Tabs used, no trailing whitespace).

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/64926#comment:16>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list