Compare commits

...
Author SHA1 Message Date
Josh Hawkins 16784d055c normalize whitespace in custom export ffmpeg args
The custom export validator tokenized args on any whitespace, but the export command was built by splitting on single spaces, so repeated spaces, tabs, or newlines produced a different argv than the one that was validated. The exporter now rejoins custom args with single spaces so ffmpeg receives exactly the tokens the validator checked.
2026-11-23 09:38:33 -06:00
Josh HawkinsandGitHub 3bca9b8676 Miscellaneous fixes (#25048)
CI / AMD64 Smoke Test (push) Blocked by required conditions
CI / ARM Build (push) Waiting to run
CI / Jetson Jetpack 6 (push) Waiting to run
CI / AMD64 Extra Build (push) Blocked by required conditions
CI / AMD64 Build (push) Waiting to run
CI / ARM Extra Build (push) Blocked by required conditions
CI / Assemble and push default build (push) Blocked by required conditions
CI / Synaptics Build (push) Blocked by required conditions
* add default filters for labels tracked at runtime

Adding a tracked label through Debug Replay or a profile left it without an object filter, so the first detection raised a KeyError in the false positive check and killed detected_frames_processor, stopping detection on every camera. Runtime objects updates now create a default filter for each tracked label that lacks one, the same as startup.

* fix nginx header inheritance and ws proxy path

Locations that include auth_request.conf declare their own add_header lines, so nginx dropped the server-level nosniff and Referrer-Policy headers on /recordings/, /exports/, /ws, /live/*, and several /api/ routes. auth_request.conf now includes security_headers.conf itself, and the duplicate includes in /vod/, /stream/, /clips/, and /api/ are removed. The /ws proxy_pass no longer carries a trailing slash, so nginx forwards the original path instead of rewriting /ws to /, which closes the path normalization gap gixy flagged.

* don't end push notification titles with "detected in" when there are no zones

* include audio labels in push notification titles

* use a plain anchor for the camera webui_url link

react-router 7.18.6 throws during render when a Link target looks like a scheme URL but isn't scheme://, so a malformed webui_url such as http:/192.168.1.5 (which the camera form accepts) crashed the object debug view into the route error boundary. A plain anchor renders any value, and a URL with a leading space no longer becomes a relative link.

* catch all OSErrors when moving the preview restart cache
2026-11-23 07:02:15 -07:00
10 changed files with 108 additions and 13 deletions
@@ -22,3 +22,6 @@ add_header Set-Cookie $auth_cookie;
## Pass the location header back up if it exists
auth_request_set $redirection_url $upstream_http_location;
add_header Location $redirection_url;
## The add_header lines above stop this location inheriting server-level headers
include security_headers.conf;
@@ -152,7 +152,6 @@ http {
sub_filter '.m4s' '.m4s$is_args$args';
sub_filter '.mp4"' '.mp4$is_args$args"';
include security_headers.conf;
add_header Cache-Control "no-store";
expires off;
@@ -161,7 +160,6 @@ http {
location /stream/ {
include auth_request.conf;
include security_headers.conf;
add_header Cache-Control "no-store";
expires off;
@@ -185,7 +183,6 @@ http {
}
expires 7d;
include security_headers.conf;
add_header Cache-Control "public";
autoindex on;
root /media/frigate;
@@ -226,7 +223,7 @@ http {
location /ws {
include auth_request.conf;
proxy_pass http://mqtt_ws/;
proxy_pass http://mqtt_ws;
include proxy.conf;
}
@@ -290,7 +287,6 @@ http {
location /api/ {
include auth_request.conf;
include security_headers.conf;
add_header Cache-Control "no-store";
expires off;
proxy_pass http://frigate_api/;
+9 -1
View File
@@ -581,6 +581,7 @@ class WebPushClient(Communicator):
sorted_objects.add(obj)
sorted_objects.update(payload["after"]["data"]["sub_labels"])
sorted_objects.update(payload["after"]["data"]["audio"])
image = f"{payload['after']['thumb_path'].replace(BASE_DIR, '')}"
ended = state == "end" or state == "genai"
@@ -617,7 +618,14 @@ class WebPushClient(Communicator):
else:
formatted_zone_names.append(titlecase(zone_name.replace("_", " ")))
title = f"{titlecase(', '.join(sorted_objects).replace('_', ' '))}{' was' if state == 'end' else ''} detected in {', '.join(formatted_zone_names)}"
object_names = titlecase(
", ".join(sorted(sorted_objects)).replace("_", " ")
)
title = f"{object_names}{' was' if state == 'end' else ''} detected"
if formatted_zone_names:
title += f" in {', '.join(formatted_zone_names)}"
message = f"Detected on {camera_name}"
if ended:
+1 -1
View File
@@ -379,7 +379,7 @@ def move_preview_frames(loc: str) -> None:
src,
dst,
)
except shutil.Error:
except OSError:
logger.error(
"Failed to move preview restart cache from %s to %s",
src,
+14 -2
View File
@@ -261,6 +261,18 @@ def validate_ffmpeg_args(args: str) -> tuple[bool, str]:
return True, ""
def normalize_ffmpeg_args(args: str | None) -> str | None:
"""Rejoin args with single spaces.
validate_ffmpeg_args tokenizes on any whitespace, while export commands are
built with split(" "). Normalizing keeps the two token lists identical.
"""
if args is None:
return None
return " ".join(args.split())
class PlaybackSourceEnum(str, Enum):
recordings = "recordings"
preview = "preview"
@@ -327,8 +339,8 @@ class RecordingExporter(threading.Thread):
self.end_time = end_time
self.playback_source = playback_source
self.export_case_id = export_case_id
self.ffmpeg_input_args = ffmpeg_input_args
self.ffmpeg_output_args = ffmpeg_output_args
self.ffmpeg_input_args = normalize_ffmpeg_args(ffmpeg_input_args)
self.ffmpeg_output_args = normalize_ffmpeg_args(ffmpeg_output_args)
self.cpu_fallback = cpu_fallback
self.chapters = chapters
self.stream = stream
+27
View File
@@ -4,6 +4,7 @@ from unittest.mock import Mock, patch
import frigate.genai
from frigate.config import GenAIProviderEnum
from frigate.config.config import RuntimeFilterConfig
from frigate.const import MODEL_CACHE_DIR, REDACTED_CREDENTIAL_SENTINEL
from frigate.genai import GenAIClient
from frigate.models import Event, Recordings, ReviewSegment
@@ -98,6 +99,32 @@ class TestHttpApp(BaseTestHttp):
assert response.status_code == 200
assert app.frigate_config.cameras["front_door"].objects.track == ["person"]
def test_config_set_in_memory_adds_filters_for_new_tracked_labels(self):
self.minimal_config["cameras"]["front_door"]["objects"] = {
"track": ["person"],
}
app = super().create_app()
app.config_publisher = Mock()
with AuthTestClient(app) as client:
response = client.put(
"/config/set",
json={
"requires_restart": 0,
"skip_save": True,
"update_topic": "config/cameras/front_door/objects",
"config_data": {
"cameras": {
"front_door": {"objects": {"track": ["person", "cat"]}}
}
},
},
)
assert response.status_code == 200
filters = app.frigate_config.cameras["front_door"].objects.filters
assert isinstance(filters["cat"], RuntimeFilterConfig)
@patch("frigate.detectors.detector_config.load_labels")
def test_config_set_in_memory_rebinds_replay_model_on_scene_change(
self, mock_labels
+31
View File
@@ -143,6 +143,37 @@ class TestValidateFfmpegArgs(unittest.TestCase):
self.assertRejected("-metadata comment=x")
class TestCustomArgsTokenization(unittest.TestCase):
"""The built command must contain exactly the tokens the validator checked."""
def test_irregular_whitespace_does_not_shift_tokens(self) -> None:
output_args = "-c:v libx264\t-crf 23\n -r 25 "
self.assertTrue(validate_ffmpeg_args(output_args)[0])
with patch("frigate.record.export.Path.mkdir"):
exporter = RecordingExporter(
MagicMock(),
"front_abc123",
"front",
None,
None,
1_000,
2_000,
PlaybackSourceEnum.recordings,
ffmpeg_input_args=" -an ",
ffmpeg_output_args=output_args,
)
exporter.config.ffmpeg.ffmpeg_path = "ffmpeg"
exporter.staged_runs = ["/cache/stage_0.mp4"]
cmd, _ = exporter.get_record_export_command("/exports/out.mp4")
for token in cmd[: cmd.index("-metadata")]:
self.assertNotEqual(token, "")
self.assertEqual(token.split(), [token])
self.assertIn("-c:v libx264 -crf 23 -r 25", " ".join(cmd))
class TestExportVideoPath(unittest.TestCase):
"""Tests for the file path an export takes once the user names it."""
+11
View File
@@ -8,6 +8,7 @@ from unittest.mock import MagicMock, patch
from frigate.config import BirdseyeModeEnum, FrigateConfig
from frigate.config.camera.profile import CameraProfileConfig
from frigate.config.config import RuntimeFilterConfig
from frigate.config.profile import ProfileDefinitionConfig
from frigate.config.profile_manager import PERSISTENCE_FILE, ProfileManager
from frigate.const import MODEL_CACHE_DIR
@@ -502,6 +503,16 @@ class TestProfileManager(unittest.TestCase):
back = self.config.cameras["back"]
assert back.notifications.enabled is True
@patch.object(ProfileManager, "_persist_active_profile")
def test_activate_profile_adds_filters_for_new_tracked_labels(self, mock_persist):
"""Labels a profile adds to objects.track get default filters."""
err = self.manager.activate_profile("armed")
assert err is None
filters = self.config.cameras["front"].objects.filters
for label in ["person", "car", "package"]:
assert isinstance(filters[label], RuntimeFilterConfig)
@patch.object(ProfileManager, "_persist_active_profile")
def test_deactivate_profile(self, mock_persist):
"""Deactivating a profile restores base config."""
+8 -1
View File
@@ -1191,7 +1191,11 @@ def apply_section_update(camera_config, section: str, update: dict) -> str | Non
Returns:
None on success, or an error message string on failure.
"""
from frigate.config.config import RuntimeFilterConfig, RuntimeMotionConfig
from frigate.config.config import (
FilterConfig,
RuntimeFilterConfig,
RuntimeMotionConfig,
)
current = getattr(camera_config, section, None)
if current is None:
@@ -1224,6 +1228,9 @@ def apply_section_update(camera_config, section: str, update: dict) -> str | Non
except AttributeError:
pass
for label in new_objects.track:
new_objects.filters.setdefault(label, FilterConfig())
# Rebuild RuntimeFilterConfig with merged global + per-object masks
for obj_name, filt in new_objects.filters.items():
merged_mask = dict(filt.mask)
@@ -184,8 +184,8 @@ export default function ObjectSettingsView({
{config?.cameras[cameraConfig.name]?.webui_url && (
<div className="mb-5 text-sm text-muted-foreground">
<div className="mt-2 flex flex-row items-center text-primary">
<Link
to={config?.cameras[cameraConfig.name]?.webui_url ?? ""}
<a
href={config?.cameras[cameraConfig.name]?.webui_url ?? ""}
target="_blank"
rel="noopener noreferrer"
className="inline"
@@ -194,7 +194,7 @@ export default function ObjectSettingsView({
camera: cameraName,
})}
<LuExternalLink className="ml-2 inline-flex size-3" />
</Link>
</a>
</div>
</div>
)}