Spoolman
Spoolman copied to clipboard
Added invalid color
Describe the bug I added a new filament via the REST API. There I gave it the color "#FF000000". I got a "500: Internal Server Error." message back.
After that the GUI no longer worked, it would complain about an internal error.
The logs say the string is too long:
spoolman_1 | File "/home/app/spoolman/spoolman/database/filament.py", line 268, in filament_changed
spoolman_1 | payload=Filament.from_db(filament),
spoolman_1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^
spoolman_1 | File "/home/app/spoolman/spoolman/api/v1/models.py", line 204, in from_db
spoolman_1 | return Filament(
spoolman_1 | ^^^^^^^^^
spoolman_1 | File "/home/app/spoolman/.venv/lib/python3.11/site-packages/pydantic/main.py", line 214, in __init__
spoolman_1 | validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
spoolman_1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spoolman_1 | pydantic_core._pydantic_core.ValidationError: 1 validation error for Filament
spoolman_1 | color_hex
spoolman_1 | String should have at most 8 characters [type=string_too_long, input_value='#FF000000', input_type=str]
spoolman_1 | For further information visit https://errors.pydantic.dev/2.10/v/string_too_long
To Reproduce
Create a vendor, then create a new filament with the following json-data:
{
"name": "PolyTerra Charcoal Black",
"vendor_id": 1,
"material": "PLA",
"price": 20,
"density": 1.24,
"diameter": 1.75,
"weight": 1000,
"spool_weight": 140,
"article_number": "PM70820",
"comment": "",
"settings_extruder_temp": 210,
"settings_bed_temp": 60,
"color_hex": "#FF000000",
"extra": {}
}
Ie putting the data above in test.json and running:
wget --header="content-type: application/json" --method=POST --body-file=test.json http://localhost:7912/api/v1/filament
Expected behavior I would expect the filament creation to fail with an error message. I would also expect the field with the invalid data to be cleared when reading the data from the database.
Spoolman Host (please complete the following information):
- Installation type: Docker
- Installed version: v0.22.1
- OS and Distro: Raspbian
- Database type: SQLite
Desktop (please complete the following information):
- OS: Debian Bookworm
- Browser: Firefox