Bug 16517 - layerindex: REST API returns 500, or kills the worker, for an invalid "filter" or "orderby" instead of 400
Summary: layerindex: REST API returns 500, or kills the worker, for an invalid "filter...
Status: NEW
Alias: None
Product: Layer Index
Classification: Yocto Project Subprojects
Component: Layer Index (show other bugs)
Version: 6.1
Hardware: All Multiple
: Medium normal
Target Milestone: 6.2
Assignee: Tim Orling
QA Contact: apoorv sangal
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2026-11-16 04:19 UTC by Tim Orling
Modified: 2026-11-16 04:44 UTC (History)
0 users

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Orling 2026-11-16 04:19:31 UTC
The REST API (layerindex/querysethelper.py) handles bad query parameters badly:

- A filter or orderby naming an unknown field, or with the wrong number of ":" separators, raises BaseException in get_search_tuple(). Django and the WSGI server don't catch BaseException: under uWSGI the worker dies and the client gets a 502, e.g.
    /layerindex/api/layerItems/?filter=pn:x
    /layerindex/api/layerItems/?orderby=%20
  The log shows: BaseException: Invalid filter ('pn', [...list of valid fields...])
- A value of the wrong type for the field raises ValueError and gives a 500, e.g.
    /layerindex/api/layerItems/?filter=id:abc
    ValueError: Field 'id' expected a number but got 'abc'.

Both should be a 400 with a short message (e.g. rest_framework.exceptions.ParseError or ValidationError). Found by fuzz testing a bench instance (layers.moto-timo.io); the same requests fail on MariaDB and PostgreSQL. A fuzz pass of the API gives several hundred of these.