[wp-trac] [WordPress Trac] #49252: REST API response not valid for null on 5.3.2

WordPress Trac noreply at wordpress.org
Mon Jan 20 21:24:01 UTC 2020


#49252: REST API response not valid for null on 5.3.2
-------------------------------+------------------------------
 Reporter:  jankadlec          |       Owner:  (none)
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  REST API           |     Version:  5.3
 Severity:  normal             |  Resolution:
 Keywords:  reporter-feedback  |     Focuses:
-------------------------------+------------------------------

Comment (by jankadlec):

 Hi @TimothyBlynJacobs

 I have this REST resource: /product/2/metafield/_meta

 If the product 2 is not mapped to any product, the REST API is returning
 404 code - it's error, and client side of the API will tackle this as an
 error...

 if the _meta metafield is not found on product 2, it's not error, that
 metafield just does not exists and null is expected with 200 code

 There is no RFC that you can refer to state that is should be implemented
 it using 404 or returning null JSON + 200, it's just on API designer to
 specify this IMHO


 Hardwiring this (result === null) condition you eliminate that finegrained
 controll of that API design and you force my client side to distinguish
 between "two 404" errors, treating one as non recoverable error, second as
 recoverable error, actually only "sort of flag, that is forcibly returned
 by WP design, as we have no other option to return 'not found' in soft
 way" - and moreover to parse 404 body to detect that type - which would
 break the simple API usage - 200 = OK, 404 = nonrecoverable error


 Why was this introduced please?

 Thank you in advance

 Jan

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


More information about the wp-trac mailing list