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
2026-01-18 22:45:29 +01:00
2023-07-04 11:45:25 +02:00
2023-05-28 23:10:36 +02:00
2026-07-07 09:48:12 +00:00

Icon of a filament spool

Keep track of your inventory of 3D-printer filament spools.

Spoolman is a self-hosted web service designed to help you efficiently manage your 3D printer filament spools and monitor their usage. It acts as a centralized database that seamlessly integrates with popular 3D printing software like OctoPrint and Klipper/Moonraker. When connected, it automatically updates spool weights as printing progresses, giving you real-time insights into filament usage.

Static Badge GitHub Release

Features

  • Filament Management: Keep comprehensive records of filament types, manufacturers, and individual spools.
  • API Integration: The REST API allows easy integration with other software, facilitating automated workflows and data exchange.
  • Real-Time Updates: Stay informed with live spool updates through Websockets, providing immediate feedback during printing operations.
  • Central Filament Database: A community-supported database of manufacturers and filaments simplify adding new spools to your inventory. Contribute by heading to SpoolmanDB.
  • Web-Based Client: Spoolman includes a built-in web client that lets you manage data effortlessly:
    • View, create, edit, and delete filament data.
    • Add custom fields to tailor information to your specific needs.
    • Print labels with QR codes for easy spool identification and tracking.
    • Contribute to its translation into 18 languages via Weblate.
  • Database Support: SQLite, PostgreSQL, MySQL, and CockroachDB.
  • Multi-Printer Management: Handles spool updates from several printers simultaneously.
  • Advanced Monitoring: Integrate with Prometheus for detailed historical analysis of filament usage, helping you track and optimize your printing processes. See the Wiki for instructions on how to set it up.

Spoolman integrates with:

Web client preview: image

Security

Spoolman has no authentication. This is by design — it is built to sit on a trusted home network alongside your printers, where requiring a login for every Moonraker or OctoPrint call would only get in the way. It does mean that anyone who can reach Spoolman over the network can read and modify your entire inventory.

If your instance is reachable from beyond your own LAN, put it behind a reverse proxy that handles authentication (Authelia, Authentik, or your proxy's own basic auth). Do not forward a port to it directly.

Spoolman does defend the one boundary a browser can be tricked into crossing on your behalf: a website you visit cannot make your browser write to your Spoolman instance, or open a websocket to it, unless it is an origin you have allowed. That protection is not a substitute for the above — it does nothing about anyone already on your network.

SPOOLMAN_CORS_ORIGIN

A comma-separated list of extra browser origins allowed to talk to Spoolman, for example https://fluidd.local,https://mainsail.local. Leave it unset unless you have a browser-based client on a different origin; the built-in web client does not need it, and neither does Moonraker, OctoPrint, Home Assistant or anything else that is not a browser.

Warning

Setting it to * turns the origin checks off entirely, which means any website you happen to visit can read and modify your Spoolman data in the background. Only do this on a network you trust completely, and list the origins you actually need instead wherever you can. Debug mode (SPOOLMAN_DEBUG_MODE) has the same effect and is not meant for normal use.

If you run Spoolman behind a reverse proxy, forward the original host — nginx proxy_set_header Host $host;, Apache ProxyPreserveHost On, or the X-Forwarded-Host header, any of which is enough. Traefik, Caddy and HAProxy do this by default.

Installation

Please see the Installation page on the Wiki for details how to install Spoolman.

S
Description
Keep track of your inventory of 3D-printer filament spools.
Readme MIT
15 MiB
0 Stars 1 Watchers 0 Forks
v0.27.0
Latest
2026-09-25 08:35:18 -05:00
Languages
Python 37.8%
TypeScript 37.4%
Svelte 23%
JavaScript 0.7%
CSS 0.4%
Other 0.7%