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.
This commit is contained in:
parent
017ef14877
commit
fc35c40c18
1 changed files with 6 additions and 1 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue