diff --git a/backend/app/routes/scheduler.py b/backend/app/routes/scheduler.py index 5bf95e09..a43440ad 100644 --- a/backend/app/routes/scheduler.py +++ b/backend/app/routes/scheduler.py @@ -90,14 +90,12 @@ def set_maintenance_settings( db: Session = Depends(get_db), ) -> dict: """Admin-tune the maintenance job's rolling re-validation batch (videos re-checked per - run). Persisted to app_state; the job reads it each run.""" - s = sysconfig.spec("maintenance_revalidate_batch") - if not (s.min <= body.revalidate_batch <= s.max): - raise HTTPException( - status_code=400, - detail=f"revalidate_batch must be between {s.min} and {s.max}", - ) - sysconfig.set_value(db, "maintenance_revalidate_batch", body.revalidate_batch) + run). Persisted via sysconfig; the job reads it each run.""" + # set_value validates against the spec's min/max (one source of bounds), mirroring the config PATCH. + try: + sysconfig.set_value(db, "maintenance_revalidate_batch", body.revalidate_batch) + except (TypeError, ValueError) as exc: + raise HTTPException(status_code=400, detail=str(exc) or "Invalid value") new = sysconfig.get_int(db, "maintenance_revalidate_batch") audit.record(db, admin.id, AuditAction.MAINTENANCE_TUNE, summary=f"revalidate batch = {new}", after={"revalidate_batch": new}) db.commit() @@ -165,6 +163,7 @@ def get_scheduler( "daily_budget": sysconfig.get_int(db, "quota_daily_budget"), "backfill_reserve": sysconfig.get_int(db, "backfill_quota_reserve"), } + maint = sysconfig.spec("maintenance_revalidate_batch") return { **snap, @@ -174,7 +173,7 @@ def get_scheduler( "maintenance": { "revalidate_batch": sysconfig.get_int(db, "maintenance_revalidate_batch"), "revalidate_batch_default": settings.maintenance_revalidate_batch, - "min": sysconfig.spec("maintenance_revalidate_batch").min, - "max": sysconfig.spec("maintenance_revalidate_batch").max, + "min": maint.min, + "max": maint.max, }, }