[wp-trac] [WordPress Trac] #63766: REST API fails if subtype CPT doesnt exist in Search Endpoint
WordPress Trac
noreply at wordpress.org
Tue Jul 29 23:31:15 UTC 2025
#63766: REST API fails if subtype CPT doesnt exist in Search Endpoint
-------------------------+-----------------------------
Reporter: SirLouen | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: REST API | Version:
Severity: normal | Keywords: 2nd-opinion
Focuses: |
-------------------------+-----------------------------
If we issue this query to the REST API search endpoint:
`http://example.com/?rest_route=/wp/v2/search&search=hello&per_page=20&type=post&subtype=post
,other-type`
And `other-type` doesn't exist as a CPT
It's going to fail with:
{{{
{
"code": "rest_invalid_param",
"message": "Invalid parameter(s): subtype",
"data": {
"status": 400,
"params": {
"subtype": "subtype[1] is not one of post, page, category, post_tag,
and any."
},
"details": {
"subtype": {
"code": "rest_not_in_enum",
"message": "subtype[1] is not one of post, page, category,
post_tag, and any.",
"data": null
}
}
}
}
}}}
The expectation was that it should issue the query, simply disregarding
the non-existent subtypes.
Still, I would like to hear more opinions on this topic.
This was originally reported here:
https://github.com/WordPress/gutenberg/issues/55810
This is why I'm still not 100% confident if this is the expected
behaviour. It feels an edge case and without an use-case I can't figure
out the utility
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63766>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list