mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-05-09 05:35:30 +02:00
[GH-ISSUE #846] [Bug]: scan_external_folder stores bytes in file_metadata, causing 500 error #574
Labels
No labels
A1
automated
automated
bug
bug
Closed due to inactivity
contrib
dependencies
dependencies
duplicate
enhancement
feedback
hold
invalid
Notes
P1S
pull-request
security
security
ThumbsUp
user-report
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/bambuddy#574
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @SMAW on GitHub (Mar 29, 2026).
Original GitHub issue: https://github.com/maziggy/bambuddy/issues/846
Originally assigned to: @maziggy on GitHub.
Bug Description
When scanning an external folder that contains a .3mf file, Bambuddy raises a 500 server error due to a TypeError: 'Object of type bytes is not JSON serializable'. The root cause is that the metadata parsed from ThreeMFParser.parse() is stored in file_metadata without being cleaned, and still contains a
_thumbnail_datakey with raw bytes. These bytes are not JSON serializable, which causes the failure.Other code paths (upload_file, extract_zip_file) use a
clean_metadata()helper to remove bytes before storing, butscan_external_folderdoes not. Additionally,scan_external_foldertries to callparser.extract_thumbnail(), but this method does not exist as a public API, causing additional issues.Expected Behavior
scan_external_folder and the resulting file_metadata should work like other endpoints: metadata should be cleaned of all bytes fields (including _thumbnail_data and _thumbnail_ext) before being stored in the database. The scan should succeed, and .3mf metadata should be JSON serializable.
Steps to Reproduce
Printer Model
P1S
Bambuddy Version
0.2.2.2
Printer Firmware Version
N/A (not relevant to this bug)
Installation Method
Docker
Operating System
Docker
Relevant Logs / Support Package
Example error:
Traceback (most recent call last):
...
TypeError: Object of type bytes is not JSON serializable
...
Screenshots
No response
Additional Context
Root Cause Analysis
Affected code —
scan_external_folderinbackend/app/api/routes/library.py(around line 838):ThreeMFParser.parse()calls_extract_thumbnail()internally, which stores raw PNG bytes inself.metadata["_thumbnail_data"]. The returned dict is assigned directly tofile_metadatawithout cleanup, causingjson.dumps()to fail when SQLAlchemy tries to serialize it into the JSON column.Working code —
extract_zip_fileandupload_filein the same file use aclean_metadata()helper (around line 1304):Suggested PR plan
_thumbnail_data/_thumbnail_extfrom the parsed metadata to save the thumbnail file (same pattern as other endpoints).clean_metadata()helper before storingfile_metadatain the database.parser.extract_thumbnail()— it does not exist as a public method; thumbnail data is already present in metadata afterparse().Checklist
@SMAW commented on GitHub (Mar 29, 2026):
Same as #844 I think, only in english :) IT just generates an 500 internal server error when scanning the folder
@maziggy commented on GitHub (Mar 30, 2026):
Available/Fixed in branch dev and available with the next release or daily build.
If you find Bambuddy useful, please consider giving it a ⭐ on GitHub — it helps others discover the project!