mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-08-05 13:35:23 +02:00
Merge pull request #3160 from michael-genson/fix/coerce-empty-string-to-none
Some checks are pending
CodeQL / Analyze (javascript-typescript) (push) Waiting to run
CodeQL / Analyze (python) (push) Waiting to run
Docker Nightly Production / Backend Server Tests (push) Waiting to run
Docker Nightly Production / Frontend and End-to-End Tests (push) Waiting to run
Docker Nightly Production / Build Tagged Release (push) Blocked by required conditions
Docker Nightly Production / Notify Discord (push) Blocked by required conditions
Some checks are pending
CodeQL / Analyze (javascript-typescript) (push) Waiting to run
CodeQL / Analyze (python) (push) Waiting to run
Docker Nightly Production / Backend Server Tests (push) Waiting to run
Docker Nightly Production / Frontend and End-to-End Tests (push) Waiting to run
Docker Nightly Production / Build Tagged Release (push) Blocked by required conditions
Docker Nightly Production / Notify Discord (push) Blocked by required conditions
fix: Pydantic Validation For Empty ID String
This commit is contained in:
commit
ae03e61bb9
1 changed files with 9 additions and 0 deletions
|
@ -37,6 +37,15 @@ class UnitFoodBase(MealieModel):
|
||||||
description: str = ""
|
description: str = ""
|
||||||
extras: dict | None = {}
|
extras: dict | None = {}
|
||||||
|
|
||||||
|
@field_validator("id", mode="before")
|
||||||
|
def convert_empty_id_to_none(cls, v):
|
||||||
|
# sometimes the frontend will give us an empty string instead of null, so we convert it to None,
|
||||||
|
# otherwise Pydantic will try to convert it to a UUID and fail
|
||||||
|
if not v:
|
||||||
|
v = None
|
||||||
|
|
||||||
|
return v
|
||||||
|
|
||||||
@field_validator("extras", mode="before")
|
@field_validator("extras", mode="before")
|
||||||
def convert_extras_to_dict(cls, v):
|
def convert_extras_to_dict(cls, v):
|
||||||
if isinstance(v, dict):
|
if isinstance(v, dict):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue