Suggest: do not embed the child listing of folderish suggestions (#105) - #106
Open
reekitconcept wants to merge 1 commit into
Open
Suggest: do not embed the child listing of folderish suggestions (#105)#106reekitconcept wants to merge 1 commit into
reekitconcept wants to merge 1 commit into
Conversation
`serialize_brain()` serializes a small set of portal types in full via `ISerializeToJson` instead of from the catalog brain. plone.restapi resolves that to `SerializeFolderToJson` for any Dexterity container, which defaults to `include_items=True` - so for a folderish type every suggestion ran an extra catalog query and carried its complete child listing (`items`, `items_total`, `batching`) in the response. Nothing in the suggest UI consumes those keys, and suggest is a type-ahead endpoint, so the waste multiplies by keystrokes x suggestions on the one interaction that is meant to feel instant. Pass `include_items=False`. Plain `SerializeToJson` accepts and ignores the keyword, so no type check is needed and non-folderish types are unaffected. Also lift the inline `["Member"]` literal into `FULL_SERIALIZATION_TYPES`, so the behaviour is named and the tests can cover it without adding a `Member` content type to the fixtures.
reekitconcept
force-pushed
the
kid/105/suggest-include-items
branch
from
August 6, 2026 12:07
82ec254 to
3ec581b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #105.
What
SolrSuggest.serialize_brain()serializes a small set of portal types in fullvia
ISerializeToJsonrather than from the catalog brain. For any Dexteritycontainer, plone.restapi resolves that to
SerializeFolderToJson, whichdefaults to
include_items=True. So for a folderish suggest type, every singlesuggestion:
items,items_total,batching) inthe response.
Nothing in the suggest UI consumes those keys — it renders a title, a type and
a link.
Why it matters
Suggest is a type-ahead endpoint: it fires on nearly every keystroke, and
the cost multiplies by
keystrokes x suggestions. It degrades exactly theinteraction that is supposed to feel instant, and it does so silently — no
error, no log entry, just a fat response and extra catalog work per request.
The
Memberbranch is not dead code; the frontend has a matching render branchin
SolrSearchWidget.jsx. And folderish suggest types are not exotic:collective.person'sPersonis aContainer(it acceptsFileandImagechildren), so a person-directory intranet that surfaces people in thesuggest dropdown lands here directly, with the payload growing with each
attachment on each person.
How
Pass
include_items=Falseexplicitly. PlainSerializeToJsonaccepts andignores the keyword, so the call stays correct for both folderish and
non-folderish types — no type check needed, and non-folderish types are
completely unaffected.
The inline
["Member"]literal is lifted into a module-levelFULL_SERIALIZATION_TYPESconstant. That names the behaviour, and it lets thetest cover the folderish path without adding a
Membercontent type to thefixtures.
Tests
New
backend/tests/services/suggest/test_suggest_serialize_brain.py, threecases. They exercise
serialize_brain()directly and only request theintegrationfixture, so they need no running Solr despite living undertests/services/suggest/.Documentstands in for the folderish suggest type: with plone.volto appliedit is a
Container, so it genuinely routes throughSerializeFolderToJson—the first assertion (
is_folderish is True) pins that down, so the"no items" assertions cannot pass vacuously.
Verified the test actually catches the bug: reverting just the
include_items=Falseargument makestest_full_serialization_omits_the_child_listingfail on
assert "items" not in data. With the fix, all three pass.Note / known limitation
SerializeFolderToJsonlets the request override the keyword:So
/@solr-suggest?query=x&include_items=truestill returns the items. That isa caller opting in explicitly rather than an accidental default, so this PR
does not defend against it — recording it here so it is not a surprise later.
Scope
Small and self-contained; no API change for any existing consumer. Intended for
the batch of small fixes going into the upcoming release candidate — please
review independently, not to be merged as part of anything else.