fix: handle numeric recipeCategory from LLM/site to prevent import failure (#7026)

This commit is contained in:
Joey
2026-02-07 14:47:44 -05:00
committed by GitHub
parent b8329def91
commit f2cc8dc922
2 changed files with 8 additions and 0 deletions

View File

@@ -533,6 +533,9 @@ def clean_categories(category: str | list) -> list[str]:
# ] # ]
# #
return [cat["name"] for cat in category if "name" in cat] return [cat["name"] for cat in category if "name" in cat]
case int() | float():
# Handling for numeric values returned as categories
return []
case _: case _:
raise TypeError(f"Unexpected type for category: {type(category)}, {category}") raise TypeError(f"Unexpected type for category: {type(category)}, {category}")

View File

@@ -511,6 +511,11 @@ category_test_cases = (
], ],
expected=["Dessert", "Lunch"], expected=["Dessert", "Lunch"],
), ),
CleanerCase(
test_id="numeric",
input=4,
expected=[],
),
) )