fix: Ensure recipe ingredients have a valid reference_id (#7139)

This commit is contained in:
Michael Genson
2026-02-24 19:50:49 -06:00
committed by GitHub
parent 8fd7995681
commit 3ae455539c
2 changed files with 25 additions and 0 deletions

View File

@@ -303,6 +303,11 @@ class RecipeIngredient(RecipeIngredientBase):
reference_id: UUID = Field(default_factory=uuid4)
model_config = ConfigDict(from_attributes=True)
@field_validator("reference_id", mode="before")
@classmethod
def ensure_reference_id(cls, value) -> UUID:
return value or uuid4()
@field_validator("quantity", mode="before")
@classmethod
def validate_quantity(cls, value) -> NoneFloat: