From 726a4d3c02ff4477ecce3949d9d0892f9d38096b Mon Sep 17 00:00:00 2001 From: Martin Hohenberg Date: Fri, 19 Jun 2026 08:00:16 +0200 Subject: [PATCH] Fix UnboundLocalError for filament_low in start_job Variable was only assigned inside a nested if-block; initialise to False at the top of the filament-logging section so all code paths define it. Co-Authored-By: Claude Sonnet 4.6 --- app/routers/ui.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/routers/ui.py b/app/routers/ui.py index 384355d..123271b 100644 --- a/app/routers/ui.py +++ b/app/routers/ui.py @@ -345,6 +345,7 @@ def start_job(job_id: int, printer_id: int = Form(...), db: Session = Depends(ge db.add(JobLog(job_id=job_id, message=f"Job started on {printer.name}")) # Log filament usage against matching AMS roll in FilamentDB + filament_low = False if job.job_material and job.job_color: stl = db.query(StlCache).filter_by(filename=job.file_name).first() if job.file_name else None if stl and stl.volume_ccm: @@ -353,7 +354,6 @@ def start_job(job_id: int, printer_id: int = Form(...), db: Session = Depends(ge if roll: note = (f"POPS {job.job_uuid[:8] if job.job_uuid else job.id}: " f"{job.file_name or job.name} on {printer.name}") - filament_low = False if log_print_on_roll(roll["roll_id"], weight_g, note): db.add(JobLog(job_id=job_id, message=( f"FilamentDB: logged {weight_g} g against roll #{roll['roll_id']} "