From ccb2da5d7ab492de6458d0f652cb6384b3edb507 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Wed, 8 Jul 2026 16:47:13 +0200 Subject: Validate dimensions in the daemon /generate path The one-shot CLI already rejects non-multiple-of-8 width/height up front, but the daemon passed them straight through, so an odd dimension over HTTP produced a downstream 500 or garbled output instead of a clear error. Add the same %8 check to /generate, returning 400 with a specific message. Also correct the generate.py scope comment: the registry now holds SDXL-architecture fine-tunes, not just SDXL base. Co-Authored-By: Claude Opus 4.8 --- server.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'server.py') diff --git a/server.py b/server.py index f3be9e5..f289f64 100644 --- a/server.py +++ b/server.py @@ -84,6 +84,13 @@ class Handler(BaseHTTPRequestHandler): return if self.path == "/generate": + width = int(data.get("width", 1024)) + height = int(data.get("height", 1024)) + if width % 8 or height % 8: + # Match the one-shot CLI: reject bad dims up front with a clear + # client error instead of a downstream 500 or garbled output. + self._json(400, {"error": "width and height must be multiples of 8"}) + return try: image, elapsed = generate.generate( STATE["pipe"], @@ -92,8 +99,8 @@ class Handler(BaseHTTPRequestHandler): int(data.get("steps", 25)), float(data.get("guidance", 7.0)), data.get("seed"), - int(data.get("width", 1024)), - int(data.get("height", 1024)), + width, + height, ) except torch.OutOfMemoryError: torch.xpu.empty_cache() -- cgit v1.2.3