The /@querystring-search endpoint fails to return results when queried with paths relative to a virtual host root. While the standard /@search endpoint correctly resolves virtual paths to physical catalog paths using the VirtualRootPhysicalPath request variable, /@querystring-search passes the criteria directly to the query builder without normalization.
This causes modern frontend components (like the new Svelte-based pat-filemanager) to show empty listings when navigating into subfolders in a production environment where VHM is active.
Steps to Reproduce
- Set up a Plone site behind a Virtual Host Monster (e.g., mapping
http://plone.org/ to /Plone).
- Create a folder at
/Plone/folder.
- Call
/@querystring-search via the virtual URL http://plone.org/@querystring-search with the following JSON:
{
"query": [
{
"i": "path",
"o": "plone.app.querystring.operation.string.path",
"v": "/folder::1"
}
]
}
- Expected: The endpoint returns the children of /Plone/folder.
- Actual: The endpoint returns 0 results because it looks for a physical path /folder, which does not exist in the catalog.
Technical Details
The issue lies in plone.restapi.services.querystringsearch.get.QuerystringSearch. Unlike plone.restapi.search.handler.SearchHandler, it does not check for VirtualRootPhysicalPath in the request.
In SearchHandler._constrain_query_by_path, the following logic is applied:
vhm_physical_path = self.request.get("VirtualRootPhysicalPath")
if vhm_physical_path:
# ... prepends vhm_physical_path to the query ...
The @querystring-search implementation should adopt similar logic to ensure consistency across search services.
Proposed Solution
Update QuerystringSearch.__call__ in src/plone/restapi/services/querystringsearch/get.py to:
- Detect
VirtualRootPhysicalPath.
- Iterate through query criteria.
- For any path index, prepend the physical root to the value (handling both string and list formats).
- Preserve the ::depth suffix if present in the string value.
The
/@querystring-searchendpoint fails to return results when queried with paths relative to a virtual host root. While the standard/@searchendpoint correctly resolves virtual paths to physical catalog paths using theVirtualRootPhysicalPathrequest variable,/@querystring-searchpasses the criteria directly to the query builder without normalization.This causes modern frontend components (like the new Svelte-based
pat-filemanager) to show empty listings when navigating into subfolders in a production environment where VHM is active.Steps to Reproduce
http://plone.org/to/Plone)./Plone/folder./@querystring-searchvia the virtual URLhttp://plone.org/@querystring-searchwith the following JSON:{ "query": [ { "i": "path", "o": "plone.app.querystring.operation.string.path", "v": "/folder::1" } ] }Technical Details
The issue lies in plone.restapi.services.querystringsearch.get.QuerystringSearch. Unlike
plone.restapi.search.handler.SearchHandler, it does not check forVirtualRootPhysicalPathin the request.In
SearchHandler._constrain_query_by_path, the following logic is applied:The @querystring-search implementation should adopt similar logic to ensure consistency across search services.
Proposed Solution
Update
QuerystringSearch.__call__insrc/plone/restapi/services/querystringsearch/get.pyto:VirtualRootPhysicalPath.