From 4ad2907ae8c7ecc1c09a794b5d0b9b4eecd27684 Mon Sep 17 00:00:00 2001 From: pyr0ball Date: Wed, 8 Apr 2026 14:33:38 -0700 Subject: [PATCH] fix: use Literal type for SubmitRequest.action field --- app/sft.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/sft.py b/app/sft.py index 71cf04e..de462c7 100644 --- a/app/sft.py +++ b/app/sft.py @@ -11,6 +11,7 @@ from __future__ import annotations import logging from pathlib import Path +from typing import Literal import yaml from fastapi import APIRouter, HTTPException @@ -140,15 +141,13 @@ def get_queue(page: int = 1, per_page: int = 20): class SubmitRequest(BaseModel): id: str - action: str # "correct" | "discard" | "flag" + action: Literal["correct", "discard", "flag"] corrected_response: str | None = None @router.post("/submit") def post_submit(req: SubmitRequest): """Record a reviewer decision for one SFT candidate.""" - if req.action not in ("correct", "discard", "flag"): - raise HTTPException(422, f"Unknown action {req.action!r}") if req.action == "correct": if not req.corrected_response or not req.corrected_response.strip(): raise HTTPException(422, "corrected_response must be non-empty when action is 'correct'")