From fc35c40c18c5f58f4b7acb4c354eaca6ea9e9172 Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Sun, 5 Jul 2026 05:34:18 +0000 Subject: [PATCH] Return 404 for malformed diffusion run records in the detail route The run detail route built DiffusionTrainingRunDetail(**rec) unguarded, so a valid-JSON-but-wrong-shape record (hand-edited or an older schema) would 500 instead of reading as absent. Catch ValidationError and 404, matching how the list route skips malformed records. --- studio/backend/routes/training.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/studio/backend/routes/training.py b/studio/backend/routes/training.py index 74088ab886..35d6921605 100644 --- a/studio/backend/routes/training.py +++ b/studio/backend/routes/training.py @@ -1339,7 +1339,12 @@ async def get_diffusion_training_run( rec = get_diffusion_run(job_id) if rec is None: raise HTTPException(status_code = 404, detail = "No such training run.") - return DiffusionTrainingRunDetail(**rec) + try: + return DiffusionTrainingRunDetail(**rec) + except ValidationError: + # A malformed on-disk record (hand-edited / older shape) should read as absent + # rather than 500 the endpoint, mirroring how the list route skips bad records. + raise HTTPException(status_code = 404, detail = "No such training run.") # Extensions accepted into an image-training dataset folder: images the trainer reads,