Make WordPress Core

Opened 4 years ago

Last modified 4 years ago

#51909 new defect (bug)

REST API inconsistencies

Reported by: icameron's profile icameron Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.8
Component: REST API Keywords:
Focuses: Cc:

Description (last modified by SergeyBiryukov)

Changeset [39967] introduced a new behavior in parts of the API. A request for posts with a page parameter that is out of range results in a status 400 and rest_post_invalid_page_number error response.

This is different behavior than the class-wp-rest-users-controller, which happily returns a status 200 with an empty array, and it always has. Status 200 with an empty array is the more correct behavior, in my opinion.

A status 400 would be for bad requests, not for valid requests that result in empty results. Would you return a status 400 for a search filter with no results? That's conceptually similar to an out-of-range page in the parameters. Regardless, the most important for developer experience, I think, is stability and consistency. Unfortunately this change introduced instability (when people upgrade from old versions) and inconsistency (when new developers write clients for the rest api and get different behavior from posts than from users).

Change History (1)

#1 @SergeyBiryukov
4 years ago

  • Description modified (diff)
  • Version set to 4.8

Hi there, welcome to WordPress Trac! Thanks for the report.

[39967] went into WordPress 4.8, setting the Version field accordingly to reflect that as the earliest applicable version.

Note: See TracTickets for help on using tickets.