id,summary,reporter,owner,description,type,status,priority,milestone,component,version,severity,resolution,keywords,cc,focuses 52106,REST API json_encode error results in `null` response,atimmer,TimothyBlynJacobs,"When an endpoint returns data that results in an error when json serialising, the REST API code outputs `null`. From the code the intention is to output the JSON encoding error instead. I tested this on 5.4 and 5.6. A dummy plugin to reproduce this: {{{#!php \WP_REST_Server::READABLE, 'callback' => function() { return new \WP_REST_Response(INF); }, 'permission_callback' => '__return_true', 'args' => array(), ), ) ); }); }}} Go to `/wp-json/v1/show-bug` and see that `null` is the output. Fixing this saves developers time by preventing them from having to debug this. I believe the expected response is ""{""code"":""rest_encode_error"",""message"":""Inf and NaN cannot be JSON encoded"",""data"":{""status"":500}}"". With the PR/patch that is the response I get.",defect (bug),closed,normal,5.7,REST API,,normal,fixed,has-patch,,rest-api