The @search route drops all but the last value of a repeated parameter

Open Beginner friendly
#377 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
react, typescript
Domain
api, backend

Research direction

Start in packages/cmsui/routes/search.tsx and read how the @search route converts URL query parameters before making its search request. Reproduce the issue with two portal_type values in either order, then verify both values reach the request and results include both content types.

Written by the indexing model from the issue text.

Description

01 type: bug 30 needs: triage

The @search route of @plone/cmsui (/@search/<path>) keeps only the last value of a repeated query parameter. A search for portal_type=Image&portal_type=News%20Item returns only news items, while Plone returns both types for the same query.

The route reads the query string in packages/cmsui/routes/search.tsx with:

const query = Object.fromEntries(new URL(request.url).searchParams.entries());

Object.fromEntries keeps one value per key, so each repeated value overwrites the previous one. Any multi-value filter (portal_type, review_state, Subject, UID…) silently loses values.

To Reproduce
Steps to reproduce the behavior:

  1. Have at least one Image and one News Item in the site.
  2. Log in to Aurora, so private items are included.
  3. Go to http://localhost:3000/@search/?portal_type=Image&portal_type=News%20Item.
  4. See that items only contains News Items.
  5. Swap the order, http://localhost:3000/@search/?portal_type=News%20Item&portal_type=Image, and see that items only contains Images.

Expected behavior
Items of both types, in both orders, as Plone returns for the same query at http://localhost:8080/Plone/++api++/@search?portal_type=Image&portal_type=News%20Item (Zope turns a repeated parameter into a list).

Software (please complete the following information):

  • OS: Windows 11
  • Browser: Chrome
  • Plone Aurora Version: main at 210cf0039 (@plone/aurora 1.0.0-alpha.22, @plone/cmsui 1.0.0-alpha.15)
  • Plone Version: 6.2.2 (plone/server-dev:6.2.2, make backend-docker-start)
  • Plone REST API Version: the one in plone/server-dev:6.2.2

Additional context
No screen in core sends repeated parameters to this route today; I found it while building a block that lists items of several content types. It affects any add-on or future screen that filters @search by more than one value.

Related: #71 (the original search route task).

Dominant language
JavaScript
Stars
10
Forks
9
Avg merge
4d 7h
Merged PRs (30d)
54

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from plone/aurora

All issues in plone/aurora

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.