mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-05-09 08:25:54 +02:00
[GH-ISSUE #1204] [Bug]: Archive created with wrong plate metadata when consecutive plates of the same model are printed #872
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
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-maziggy-1#872
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 @BurntOutHylian on GitHub (May 3, 2026).
Original GitHub issue: https://github.com/maziggy/bambuddy/issues/1204
Originally assigned to: @maziggy on GitHub.
Component
Bambuddy
Bug Description
When two different plates of the same model are printed back-to-back, the second print's archive can be created using the first plate's 3MF metadata.
At the moment Bambuddy detects the print_start MQTT event, the printer's MQTT state (subtask_name / filename) may still reflect the previous plate's job.
Bambuddy downloads the wrong 3MF from the printer's FTP and creates the archive with that file's metadata (wrong print name, slicer time estimate, and filament slot data) all locked in at row creation. There is no follow-up to correct.
Diagnosis in Support package section
Expected Behavior
Each archive should reflect its actual plate: correct name (e.g. MyModel - Plate 1, not MyModel - Plate 2), correct slicer estimate, and correct per-slot filament data.
Steps to Reproduce
With a print/printer
Via live DB Data
Printer Model
P2S
Bambuddy Version
0.2.3.2, dev branch
SpoolBuddy Version
No response
Printer Firmware Version
01.02.00.00
Installation Method
Docker
Operating System
Docker
Relevant Logs / Support Package
Diagnosis
When Bambuddy detects a print start via MQTT, it immediately reads subtask_name and filename from the MQTT payload to identify and download the 3MF from the printer's FTP. There is no check that this data belongs to the newly-started job.
If the printer's MQTT state hasn't transitioned yet (still reflecting the previous job), Bambuddy downloads the wrong plate's 3MF. The archive is created from that file's metadata.
Suggestion/Thoughts
Simply not trusting subtask_name doesn't help unless there's an alternative source of truth to validate against.
The filename field from MQTT (e.g., /data/Metadata/plate_1.gcode) contains the plate number explicitly, and is plate-specific, but subtask_name is model-level and can lag. The 3MF parser also extracts _plate_index from the parsed file, so after download you can cross-check: "the file I downloaded claims to be Plate 2, but filename says I'm printing plate 1."
I think there's 2 viable options here, but tbh I'm still understanding the 3MF parsing portion of Bambuddy.
Step 1, Detect
After parsing the downloaded 3MF, extract the expected plate number from filename via regex (plate_(\d+)) and compare it against the _plate_index the parser read from the file. A mismatch would identify that the wrong 3MF was used
Step 2, Correct the wrong 3MF use
This is where I'm still learning. I can think of 2 options here:
Option A: Re-download using filename
On mismatch, drop subtask_name and retry the FTP download using the plate-specific path derived from filename (e.g., plate_1.gcode.3mf). This fix has a higher-fidelity, but ends up adding an extra FTP round-trip on affected prints. It also assumes the plate-specific file is present on the printer's FTP.
Option B: Fall back to no-3MF archive
On mismatch, discard the parsed metadata and create the archive without 3MF data (the existing fallback path at [main.py:2154] already handles this). The archive name would fall back to the raw filename stem, which at least reflects the correct plate. This is easier, but ends up losing the slicer estimates/metadata
This assumes filename from MQTT is reliably plate-specific and not also stale. That's probably worth verifying. If both subtask_name and filename lag together, Option A's re-download would still target the wrong file.
Screenshots
No response
Additional Context
No response
Checklist
@maziggy commented on GitHub (May 4, 2026):
Thanks for the very thorough diagnosis — your analysis was correct end-to-end and pointed me right at the missing check.
Confirmed the flow:
Going with your Option A as the primary fix and Option B (no-3MF fallback) only when the corrected re-download also can't find a matching file. Concretely:
Validation only runs when parse_plate_id(filename) returns a value, so single-plate / cloud-named / non-Bambu jobs are unaffected.
Your hypothesis about filename not lagging together with subtask_name is the load-bearing assumption — if both lag, the retry will fail and the no-3MF fallback kicks in, so the archive name still reflects the right plate (derived from the fresh gcode_file path). Worst case: missing slicer estimate / per-slot filaments on the affected print, never wrong-plate metadata silently locked in.
Available/Fixed in branch dev and available with the next release or daily build. Please let me know if it works for you.
If you find Bambuddy useful, please consider giving it a ⭐ on GitHub — it helps others discover the project!
@BurntOutHylian commented on GitHub (May 4, 2026):
Confirmed. Nice! And super quick turnaround