Repository navigation
Conversation
getMetaDataFrom3mf() returns {} on every failure path, but both callers
immediately hard-index it, so a failed or unparseable 3MF raises
KeyError: 'image' (cloud path) or KeyError: 'file' (local path) inside
the MQTT callback instead of just recording a print without a thumbnail.
The local-path crash is issue drndos#78. The `if PENDING_PRINT_METADATA:`
guard above it does not help, because by then {} has had print_type,
task_id and subtask_id written onto it and is truthy.
insert_print() stores both values in nullable columns, so .get() keeps
the print recorded and leaves MQTT handling alive.
Addresses drndos#78
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
getMetaDataFrom3mf()returns{}on every failure path (RequestException,BadZipFile,ParseError, bareException—tools_3mf.py:293-323). Both callersthen immediately hard-index it:
So any transient FTP/network hiccup, or a 3MF the parser doesn't like, turns into
KeyError: 'image'orKeyError: 'file'inside the MQTT callback.This is the crash in #78 ("When print starts from printer - openspoolman throws
errors",
KeyError: 'file'). It's also the root of the reports where print historysilently stops populating: the exception escapes mid-way through building
PENDING_PRINT_METADATA, leaving the module global half-initialised.Note the
if PENDING_PRINT_METADATA:guard added at:310does not help — by thetime it runs,
{}has already hadprint_type/task_id/subtask_idwritten ontoit, so it is truthy but still missing
fileandimage.The downstream
["complete"]cascade from this was already fixed in #76; this isthe same class of bug at the two sites that actually raise first.
Fix
.get()at both call sites.insert_print()already stores these straight intonullable columns, so
Noneis fine and the print is still recorded — just withouta thumbnail/filename — instead of taking down MQTT handling.
Testing
These guards have been running in production on a LAN-mode P1S since 2026-08 (on
0.3.0, rebased ontomainand redeployed 2026-09-03). I hit the'image'variant originally as a repeating crash: the exception escaped mid-way through
building
PENDING_PRINT_METADATA, and every subsequent MQTT message then dieduntil the container was restarted, so tracking went silently dead.
I have not written an automated repro for either call site — the change is a
narrow
.get()on two values thatinsert_print()already accepts as NULL. The'file'traceback in #78 is a reporter's, not mine.