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:
2026-02-26 08:36:13 +01:00
parent 19cbd505d4
commit 8f4f7f245b
2 changed files with 5 additions and 5 deletions
+2 -2
View File
@@ -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 = ""