Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#52317 closed enhancement (fixed)

REST API: Improve JSON Schema validation error codes

Reported by: timothyblynjacobs's profile TimothyBlynJacobs Owned by: timothyblynjacobs's profile TimothyBlynJacobs
Milestone: 5.7 Priority: normal
Severity: normal Version: 4.7
Component: REST API Keywords: has-patch commit dev-reviewed
Focuses: Cc:

Description

rest_validate_value_from_schema currently has a mix of error codes in use. Some are nice and specific like rest_invalid_date but most are the unhelpful rest_invalid_param. Right now, this doesn't have much of an impact since the individual errors from rest_validate_value_from_schema are not returned to clients. But in preparation for #46191, we should take this opportunity to make them more useful, as after it may be more of a BC break.

Change History (7)

This ticket was mentioned in PR #875 on WordPress/wordpress-develop by TimothyBJacobs.


4 years ago
#1

  • Keywords has-patch added

#2 @TimothyBlynJacobs
4 years ago

  • Owner set to TimothyBlynJacobs
  • Resolution set to fixed
  • Status changed from new to closed

In 50007:

REST API: Add more specific error codes for schema validation.

Previously, the majority of JSON Schema validation errors returned a generic rest_invalid_param error code. In preparation for #46191, where the underlying validation error code will be exposed, this commit adds specific error codes for each failure scenario.

Fixes #52317.

#4 @TimothyBlynJacobs
4 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Reopening to backport r50461 to 5.7.

This ticket was mentioned in Slack in #core by hellofromtonya. View the logs.


4 years ago

#6 @desrosj
4 years ago

  • Keywords commit dev-reviewed added

[50461] looks good to backport.

#7 @SergeyBiryukov
4 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 50470:

REST API: Correct error code for the maxItems keyword.

Follow-up to [50007].

Props TimothyBlynJacobs.
Reviewed by desrosj, SergeyBiryukov.
Merges [50461] to the 5.7 branch.
Fixes #52317.

Note: See TracTickets for help on using tickets.