Commit Graph
14 Commits
Author SHA1 Message Date
Donkie 5d812e269e fix: return 400 instead of 500 for malformed sort parameters
Each list endpoint parsed `sort` inline with a bare split(":"), so `?sort=name`
raised "not enough values to unpack" and `?sort=name:sideways` a KeyError from
SortOrder[...]. Both surfaced as a 500 (todo.md task 8).

parse_nested_field also gated on hasattr, so any attribute that merely existed
passed through to order_by() -- `?sort=metadata:asc` got as far as calling
.asc() on the MetaData object. It now checks the SQLAlchemy mapper's columns,
so only real columns are accepted; relationship traversal through filament. and
vendor. still works.

Sort parsing moves into a shared parse_sort() used by all four call sites, which
tolerates surrounding whitespace and rejects a missing colon, an empty field
name or an unknown direction with a message saying what was expected.

database/vendor.py turned out not to use parse_nested_field at all -- it did a
bare getattr(models.Vendor, fieldstr) -- so /vendor kept returning 500 even
after the helper was fixed. It now uses the shared helper like filament.py.

All three endpoints verified end-to-end: 400 for each malformed form, 200 for
valid single and multi-field sorts, and no unhandled exceptions in the log.
2026-07-27 20:03:14 +02:00
Donkie b942d1f8a1 Replaced pdm with uv, updated backend deps, python 3.10 minimum, simplified install script 2026-01-07 22:01:02 +01:00
inukiwi 1f3c1c0ad5 Do not ignore empty lists in database selects 2025-01-15 23:14:09 +01:00
Donkie b00075ab87 Added backend support to perform exact matches 2024-05-25 20:56:22 +02:00
Donkie cf8d7472f5 Added backend filament search by similar color 2023-12-19 21:37:07 +01:00
Donkie 597dca7c28 Fixed combining empty and non-empty filter
Previously it would then act as a wildcard filter
2023-09-20 21:02:49 +02:00
Donkie 6ee3b8df70 Added support for multiple int where's 2023-09-16 11:13:30 +02:00
Donkie 6d68a40313 Added support for multiple string where's 2023-09-16 11:13:30 +02:00
Donkie e436aa4975 Added tests for spool find sorting 2023-09-16 11:13:30 +02:00
Donkie f47eacd2a9 Added support for finding empty vendor fields 2023-09-16 11:13:30 +02:00
Donkie de16dd7be0 Added database support for finding empty fields 2023-09-16 11:13:30 +02:00
Donkie e2d937aaf1 Added x-total-count response header 2023-09-16 11:13:30 +02:00
Donkie 9d51ee49ed Serverside sort and limit for vendor and filaments 2023-09-16 11:13:30 +02:00
Donkie 4fdea75e3f Serverside spool sorting 2023-09-16 11:13:30 +02:00