Skip to content

REST: Pass name filter to patch list - #52

Open
0z5a wants to merge 1 commit into
getpatchwork:mainfrom
0z5a:fix-rest-list-name-filter
Open

0z5a wants to merge 1 commit into
getpatchwork:mainfrom
0z5a:fix-rest-list-name-filter

Conversation

@0z5a

@0z5a 0z5a commented Nov 19, 2026

Copy link
Copy Markdown

Fixes #51.

I started from #51 and checked it against the code. pwclient list takes the name as the positional STR argument, and shell.py passes it to patch_list(name=...). The XML-RPC backend turns it into name__icontains, but REST.patch_list never adds it to the request, so with the REST backend (now the default) every patch of the project is listed.

Patchwork's patch list endpoint searches patch names with the q parameter (search_fields = ('name',) in PatchList, and the q Search parameter in the API schema for /api/1.0/patches). This change adds the name as q to the filters.

How I found it

I compared the two patch_list implementations in pwclient/api.py: the XML-RPC one handles name, the REST one skips it. Then I checked the server side on patchwork.ozlabs.org: /api/1.0/patches/?project=patchwork returns unrelated patches, and adding &q=pwclient returns only patches with "pwclient" in the name.

Where this can show up in practice

Anyone who runs pwclient list <name> to find a patch by its subject, for example to get its ID for pwclient git-am, gets the full patch list of the project instead, which on a busy project is a long list with no sign that the filter was ignored. This is my estimate beyond the report in #51.

Testing

  • New test_rest_client__patch_list__name in tests/test_api.py: checks that patch_list(name='foo') sends q=foo. It fails without the change.
  • pytest: 90 passed (Python 3.12).
  • Ran the patched CLI against patchwork.ozlabs.org with the REST backend: pwclient list -p patchwork "git-am action" returns only patch 127647 ("patchwork: new pwclient git-am action").
  • Release note added.
  • Not run: tox and the pre-commit hooks.

'pwclient list STR' passes the name to 'REST.patch_list', but the REST
backend dropped it and listed all patches. Patchwork's patch list
endpoint searches patch names with the 'q' parameter, so pass it there,
as the XML-RPC backend already does with 'name__icontains'.

Closes: getpatchwork#51
Signed-off-by: Dezhen Lu <dezhen.lu@student.uni-tuebingen.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pwclient list <filter_str> is silently ignored for rest backend

1 participant