Opened 8 weeks ago
#64019 new enhancement
Improve clarity of REST API meta field error message "The %s property has an invalid stored value, and cannot be updated to null."
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Awaiting Review | Priority: | normal |
| Severity: | normal | Version: | trunk |
| Component: | REST API | Keywords: | |
| Focuses: | rest-api | Cc: |
Description
The current error message for invalid meta field values in REST API is unclear and not actionable.
This message could be displayed to end user(e.g. in the block editor)
Current message:
"The %s property has an invalid stored value, and cannot be updated to null."
Related Files:
- [wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php#L208](https://github.com/WordPress/wordpress-develop/blob/ebd415b045a2b1bbeb4d227e890c78a15ff8d85e/src/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php#L208)
- [wp-includes/rest-api/fields/class-wp-rest-meta-fields.php#L170](https://github.com/WordPress/wordpress-develop/blob/ebd415b045a2b1bbeb4d227e890c78a15ff8d85e/src/wp-includes/rest-api/fields/class-wp-rest-meta-fields.php#L170)
- [wp-includes/rest-api/fields/class-wp-rest-meta-fields.php#L188](https://github.com/WordPress/wordpress-develop/blob/ebd415b045a2b1bbeb4d227e890c78a15ff8d85e/src/wp-includes/rest-api/fields/class-wp-rest-meta-fields.php#L188)
Issues:
- Unclear what "property" refers to (meta field? custom field?)
- Doesn't explain what makes the value invalid
- No guidance on how to fix the issue
Proposed improvement:
'The field "%s" contains an invalid value, and cannot be updated. Please enter a valid value or contact your site administrator.'
This message is used in 2 different controllers, so it's also possible to make variations for each class:
- For settings controller: 'The setting "%s" contains an invalid value...'
- For meta fields: 'The meta field "%s" contains an invalid value...'
Related Issues:
Gutenberg #17864: "Saving a certain meta key saves other unmodified keys" https://github.com/WordPress/gutenberg/issues/17864
This error often appears when Block Editor sends unintended empty values.
It's also possible to change Block Editor's error handling in Gutenberg project.
Note: See
TracTickets for help on using
tickets.