Miscellaneous Fixes (#25027)

* Fix GenAI structured response not handling optional fields correctly

* allow export thumbnails for camera-restricted roles

Export thumbnails under /clips/export/ weren't classified by media auth, so roles with a camera allow-list got a 403 on every thumbnail. The thumbnail now resolves to its export's camera through a thumb_path lookup, and the camera access check applies as usual.

* load i18n locales from the base url

The locale load path was relative, so any URL with a trailing slash or more than one segment (like /admin/) fetched locales from under that path, got index.html back from the nginx fallback, and broke every UI string. Locales now load from the same base url as the API, which also covers HA ingress and FRIGATE_BASE_PATH.

* make storage retained-segment test able to fail

The old test put the retained segments after 59 older unretained ones, so cleanup freed its hourly target and stopped before it ever reached them. It passed even with the retention check removed. Retained segments now come first, and cleanup needs every unretained segment after them, so it has to skip the retained ones to finish.

---------

Co-authored-by: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com>
This commit is contained in:
Nicolas Mowen
2026-11-20 07:59:53 -06:00
committed by GitHub
co-authored by Josh Hawkins
parent 4b1ae76baa
commit d85527ffd2
6 changed files with 128 additions and 56 deletions
+16 -6
View File
@@ -17,10 +17,10 @@ import re
from enum import Enum
from urllib.parse import unquote
from peewee import DoesNotExist
from peewee import DoesNotExist, Field
from frigate.config import FrigateConfig
from frigate.const import EXPORT_DIR
from frigate.const import CLIPS_DIR, EXPORT_DIR
from frigate.models import Export, User
logger = logging.getLogger(__name__)
@@ -151,6 +151,7 @@ def _resolve_clip(
# /clips/thumbs/{cam}/... → camera
# /clips/previews/{cam}/... → camera
# /clips/review/thumb-{cam}-{review_id}.webp → camera (parsed)
# /clips/export/{export_id}.{ext} → camera (DB lookup)
# /clips/faces/... → admin-only
# /clips/genai-requests/... → admin-only
# /clips/preview_restart_cache/... → admin-only
@@ -175,6 +176,11 @@ def _resolve_clip(
return MediaAuthResolution.CAMERA, camera
return MediaAuthResolution.UNRESOLVED_MEDIA, None
if second == "export" and len(parts) == 3:
return _export_camera(
Export.thumb_path, os.path.join(CLIPS_DIR, "export", parts[2])
)
if second in ("faces", "genai-requests", "preview_restart_cache"):
return MediaAuthResolution.ADMIN_ONLY, None
@@ -234,15 +240,19 @@ def _resolve_export(
if len(parts) != 2:
return MediaAuthResolution.UNRESOLVED_MEDIA, None
filename = parts[1]
full_path = os.path.join(EXPORT_DIR, filename)
return _export_camera(Export.video_path, os.path.join(EXPORT_DIR, parts[1]))
def _export_camera(
field: Field, full_path: str
) -> tuple[MediaAuthResolution, str | None]:
try:
export = Export.get(Export.video_path == full_path)
export = Export.get(field == full_path)
return MediaAuthResolution.CAMERA, export.camera
except DoesNotExist:
return MediaAuthResolution.UNRESOLVED_MEDIA, None
except Exception as e:
logger.warning("Export DB lookup failed for %s: %s", filename, e)
logger.warning("Export DB lookup failed for %s: %s", full_path, e)
return MediaAuthResolution.UNRESOLVED_MEDIA, None