Fix KeyError on keyword/tag objects without 'name' field
Tandoor recipe list API may return keyword objects without a 'name'
key, causing KeyError('name'). Use .get() with filtering across all
tag/keyword list comprehensions in both Mealie and Tandoor clients.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+2
-2
@@ -126,7 +126,7 @@ class MealieClient:
|
||||
"id": item["slug"],
|
||||
"name": item.get("name", ""),
|
||||
"image": image_url,
|
||||
"tags": [t["name"] for t in item.get("tags", [])],
|
||||
"tags": [t.get("name", "") for t in item.get("tags", []) if t.get("name")],
|
||||
"url": f"{self.base_url}/g/home/r/{item['slug']}",
|
||||
})
|
||||
return {
|
||||
@@ -177,7 +177,7 @@ class MealieClient:
|
||||
instructions.append(text)
|
||||
|
||||
# Parse tags
|
||||
tags = [t["name"] for t in data.get("tags", [])]
|
||||
tags = [t.get("name", "") for t in data.get("tags", []) if t.get("name")]
|
||||
|
||||
# Image URL
|
||||
image_url = ""
|
||||
|
||||
Reference in New Issue
Block a user