fix: Frigate face count API structure and Immich 401 error message

Frigate /api/faces response has person names as top-level keys with
lists of filenames — {person: [file, ...], "train": [...]}. The old
code incorrectly looked inside data["train"] as if it were a dict of
persons, causing 'list object has no attribute items' on every run.

Immich get_people() now checks for 401 before raise_for_status() and
logs a clear "API key invalid or expired" message instead of the raw
requests exception string.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-12 15:58:29 +00:00
co-authored by Claude Sonnet 4.6
parent 4f6967258f
commit 31e7ca5af0
2 changed files with 11 additions and 3 deletions
+4 -1
View File
@@ -35,10 +35,13 @@ def get_people() -> list[dict]:
headers=get_headers(),
timeout=10,
)
if resp.status_code == 401:
logger.error("Immich API key is invalid or expired (401 Unauthorized). Update API_KEY.")
return []
resp.raise_for_status()
return resp.json().get("people", [])
except (requests.RequestException, ValueError) as e:
logger.error(f"Failed to fetch people: {e}")
logger.error(f"Failed to fetch people from Immich: {e}")
return []