Bug 16519 - layerindex: non-numeric ids in URLs and branch_comparison parameters give 500 instead of 404
Summary: layerindex: non-numeric ids in URLs and branch_comparison parameters give 500...
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:45 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:33 UTC
Several URL patterns in layerindex/urls.py capture the primary key with [-\w]+, which matches any word, and the views pass it to the id field, so a non-numeric value raises ValueError and gives a 500:

    /layerindex/recipe/NaN/
    /layerindex/recipe/_/
    /layerindex/oe-classic/recipe/x/
    /layerindex/comparison/recipe/x/
    ValueError: Field 'id' expected a number but got 'NaN'.

The from_branch and to_branch query parameters of /layerindex/branch_comparison/ (and _plain, _rst) have the same problem through get_object_or_404(Branch, id=...):

    /layerindex/branch_comparison/?from_branch=&to_branch=1
    ValueError: Field 'id' expected a number but got ''.

The URL patterns should use <int:pk> (or \d+) so these are a 404, and the branch parameters should be validated (404 or 400). Found by fuzz testing a bench instance; the same on MariaDB and PostgreSQL.