mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-02-08 17:03:11 -05:00
fix: handle numeric recipeCategory from LLM/site to prevent import failure (#7026)
This commit is contained in:
@@ -533,6 +533,9 @@ def clean_categories(category: str | list) -> list[str]:
|
||||
# ]
|
||||
#
|
||||
return [cat["name"] for cat in category if "name" in cat]
|
||||
case int() | float():
|
||||
# Handling for numeric values returned as categories
|
||||
return []
|
||||
case _:
|
||||
raise TypeError(f"Unexpected type for category: {type(category)}, {category}")
|
||||
|
||||
|
||||
@@ -511,6 +511,11 @@ category_test_cases = (
|
||||
],
|
||||
expected=["Dessert", "Lunch"],
|
||||
),
|
||||
CleanerCase(
|
||||
test_id="numeric",
|
||||
input=4,
|
||||
expected=[],
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user