[wp-trac] [WordPress Trac] #56483: Weird oneOf behaviour upon validation of post meta value upon GET retrieval via REST API
WordPress Trac
noreply at wordpress.org
Sat Sep 3 09:23:56 UTC 2022
#56483: Weird oneOf behaviour upon validation of post meta value upon GET retrieval
via REST API
--------------------------+------------------------------
Reporter: joeyojoeyo12 | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: REST API | Version: 6.0.1
Severity: major | Resolution:
Keywords: needs-patch | Focuses: rest-api
--------------------------+------------------------------
Comment (by anna.bansaghi):
Hi, I was able to reproduce the response having `null` with your workflow,
but do not know if the cause is the same as in your case. I have
misspelled a keyword which was defined with `pattern` in the input meta.
Would you mind sharing your input meta here?
So in my case I had inserted an invalid meta with `add_post_meta()`, and
wanted the fetch it with `REST API`. However `REST API` validates the
value against the schema, and because it was invalid, so the response was
`null`.
One might argue that a detailed error response would be more useful, but a
better argue would be to use `REST API` for all operations (create, fetch,
update, delete), so all database operations will be validated against the
schema.
So my next try was using `REST API` instead of `add_post_meta()`, and the
response immediately was an error message with detailed information about
the misspelled keyword. It was not possible to create a wrong meta at the
first place!
As I said before, it is possible that your issue is caused by something
else! It would be nice :
- to see your input meta here, so we can rule out the invalid keyword
issue, and
- if you could try to use `REST API` for creating the meta, and see what
would be the response to that.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/56483#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list